Created
September 17, 2013 12:32
-
-
Save pad92/6593720 to your computer and use it in GitHub Desktop.
A tester
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
#!/usr/bin/env sh | |
# === CONFIG === | |
MYCNF='/etc/mysql/debian.cnf' | |
BIN_DEPS='bzip2 mysql' | |
# === CHECKS === | |
for BIN in $BIN_DEPS; do | |
which $BIN 1>/dev/null 2>&1 | |
if [ $? -ne 0 ]; then | |
echo "Error: Required file could not be found: $BIN" | |
exit 1 | |
fi | |
done | |
# === CORE === | |
for BDD in `mysql --defaults-extra-file=$MYCNF --skip-column-names -B -e "SHOW databases;" | egrep -v "^information_schema$|^performance_schema$"`; do | |
echo "* Processing BDD $BDD" | |
for TABLE in `mysql --defaults-extra-file=$MYCNF --skip-column-names -B $BDD -e "SHOW TABLES;" | grep -v slow_log | grep -v general_log`; do | |
echo " ** Optimize $BDD.$TABLE" | |
mysql --defaults-file=$MYCNF -e "optimize table $BDD.$TABLE" | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment