Last active
January 20, 2022 06:23
-
-
Save darkcolonist/b92b77952b268a77b1a6ad565c861b9d to your computer and use it in GitHub Desktop.
mysql read replica process watcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* * * * * /bin/sh /path/to/script/rreplica-watcher.sh 2>/dev/null >/dev/null | |
0 2 * * * /bin/sh /path/to/script/rreplica-collate.sh 2>/dev/null >/dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MYPATH='/path/to/script/' | |
TZOFFSET='+8hours' | |
OUTFILE="$MYPATH"rreplica-collated-$(date +\%Y-%m-%d_%H-%M-%S -d"$TZOFFSET").txt | |
find "$MYPATH"rreplica-watcher*txt -type f -print -exec cat {} \; \ | |
> "$OUTFILE" | |
find "$MYPATH"rreplica-watcher*txt -type f -delete | |
find "$MYPATH"rreplica-collate*txt -mtime +7 -type f -delete |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MYPATH='/path/to/script/' | |
TZOFFSET='+8hours' | |
DBHOST='localhost' | |
DBUSER='mysql_user' | |
DBPORT='3306' | |
DBPASS='PASSWORD' | |
find "$MYPATH"rreplica-watcher*txt -type f -size -1000c -delete | |
mysql -e'show full processlist' -u${DBUSER} -p${DBPASS} -P${DBPORT} -h${DBHOST} \ | |
> "$MYPATH"rreplica-watcher-$(date +\%Y-%m-%d_%H-%M-%S -d"$TZOFFSET").txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment