I'm using logrotate to rotate mysql output. When cron runs logrotate, I get frequently get an e-mail with the following content:
error: Compressing program wrote following message to stderr when compressing log /var/log/mysql/mysqld.err-20150408:
gzip: stdin: file size changed while zipping
indicating that after logrotate moved the file and called gzip on it, the file was still open and mysql was writing to it. Here's my logrotate config for mysql:
/var/log/mysql/mysql.err /var/log/mysql/mysql.log /var/log/mysql/mysqld.err {
monthly
create 660 mysql mysql
notifempty
size 5M
sharedscripts
missingok
postrotate
[ -f /var/run/mysqld/mysqld.pid ] && /bin/kill -HUP `cat /var/run/mysqld/mysqld.pid`
endscript
}
This is the unmodified file that is shipped with Gentoo's mysql package, so I doubt there are problems with it. I have no trouble with other logs being rotated.
Any ideas what may be going on?
logrotate
that has to stop writing to the file and close it, it's whatever application is writing it, in this case MySQL.