Skip to content

Instantly share code, notes, and snippets.

@hatak
Created June 1, 2012 08:58
Show Gist options
  • Save hatak/2850531 to your computer and use it in GitHub Desktop.
Save hatak/2850531 to your computer and use it in GitHub Desktop.
logrotate slowlog of MySQL
## /usr/local/etc/my.cnf
[mysqladmin]
user=root
password=hogefuga
## /etc/logrotate.d/mysql
/var/lib/mysql/mysqld-slow.log {
create 664 mysql mysql
notifempty
compress
daily
dateext
dateformat -%Y%m%d
rotate 60
olddir /var/log/mysql
missingok
postrotate
if test -x /usr/bin/mysqladmin && \
/usr/bin/mysqladmin --defaults-extra-file=/usr/local/etc/my.cnf ping &>/dev/null
then
/usr/bin/mysqladmin --defaults-extra-file=/usr/local/etc/my.cnf flush-logs
fi
endscript
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment