Skip to content

Instantly share code, notes, and snippets.

@seidler2547
Created March 14, 2016 07:37
Show Gist options
  • Save seidler2547/7c3cbeb99bab0a80d011 to your computer and use it in GitHub Desktop.
Save seidler2547/7c3cbeb99bab0a80d011 to your computer and use it in GitHub Desktop.
Cron entry to keep the MySQL log space at 90%
*/5 * * * * /bin/df /var/log/mysql -P | /bin/awk '/^\/dev/ { exit 100.0*$4/$2 < 10 }' || /usr/bin/mysql -u monitor -e "purge binary logs to '$(cd /var/log/mysql ; ls -1tr mysql-bin.[0-9]* | head -2 | tail -1)'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment