Automate MySQL defragmentation with mysqlfragfinder and crontab

After a while, your MySQL databases will be fragmented, and you need to run the MySQL optimization to defrag it. A guy name Phil Dufault had written a shell script which can find all the fragmented tables in your databases and defrag them for you:

The author's repo: https://github.com/pdufault/mysqlfragfinder



Create a crontab to run that script periodically on a given schedule. For example:

# crontab -e

...
22 4 * * 0 /usr/local/bin/mysqlfragfinder.sh  --user root --password mySuperPassword
...

That crontab will run the mysqlfragfinder.sh at 4:22 AM every Sunday.

Comments