I have this logrotate config and I am running on Ubuntu 10.04.
/var/log/mysql/mysql-slow.log { daily rotate 3 compress notifempty missingok create 660 mysql adm postrotate if test -x /usr/bin/mysqladmin && \ /usr/bin/mysqladmin ping &>/dev/null then /usr/bin/mysqladmin flush-logs fi endscript }
I put this in /etc/logrotate.d yesterday and today the log was not rotated.
Below are the things that I have done:
- I verified that the log is indeed in /var/log/mysql/mysql-slow.log
- mysqladmin lines work fine when run as root
- mysql is able to write to the mysql-slow.log
When I did this:
$ logrotate -d -f mysql-slow reading config file mysql-slow reading config info for /var/log/mysql/mysql-slow.log Handling 1 logs rotating pattern: /var/log/mysql/mysql-slow.log forced from command line (3 rotations) empty log files are not rotated, old logs are removed considering log /var/log/mysql/mysql-slow.log log needs rotating rotating log /var/log/mysql/mysql-slow.log, log->rotateCount is 3 dateext suffix '-20120329' glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' renaming /var/log/mysql/mysql-slow.log.3.gz to /var/log/mysql/mysql-slow.log.4.gz (rotatecount 3, logstart 1, i 3), renaming /var/log/mysql/mysql-slow.log.2.gz to /var/log/mysql/mysql-slow.log.3.gz (rotatecount 3, logstart 1, i 2), renaming /var/log/mysql/mysql-slow.log.1.gz to /var/log/mysql/mysql-slow.log.2.gz (rotatecount 3, logstart 1, i 1), renaming /var/log/mysql/mysql-slow.log.0.gz to /var/log/mysql/mysql-slow.log.1.gz (rotatecount 3, logstart 1, i 0), renaming /var/log/mysql/mysql-slow.log to /var/log/mysql/mysql-slow.log.1 creating new /var/log/mysql/mysql-slow.log mode = 0660 uid = 20004 gid = 4 running postrotate script running script (multiple) with arg /var/log/mysql/mysql-slow.log : " if test -x /usr/bin/mysqladmin && \ /usr/bin/mysqladmin &>/dev/null then /usr/bin/mysqladmin flush-logs fi " compressing log with: /bin/gzip removing old log /var/log/mysql/mysql-slow.log.4.gz - Where is the log that shows that logrotate was successful? I want to see if there is anything that would say that there was a problem.
- Any ideas on why the logrotate is not working?
crondrunning?mysql-server? Rungrep '/var/log/mysql' /etc/logrotate.d/*./etc/crontabfile, in the line that ends with/etc/cron.daily ). Maybe you created the logrotate config after the cron daily jobs for that day had already run?