Skip to main content

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:

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

# crontab -e

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

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