I work with CentOS5, and I have the following version of mysql :
mysql Ver 14.12 Distrib 5.0.77, for redhat-linux-gnu (i686) using readline 5.1
I want to rotate the logs of mysql using logrotate.
Let's consider I only want to rotate the file /var/lib/mysql/mysql-log.log for the example. I describe below the procedure I have followed, the logrotate behaviour I have noted, and then I give the content of my config files.
I followed these steps :
- I added a file called mysql (see the content below) in /etc/logrotate.d, with 660 rights (the file belongs to root)
 - I tried to force rotation with the command "logrotate -dv --force /etc/logrotate.conf"
 
The behaviour I noted :
- The messages produced by the command logrotate seemed to show me that /var/lib/mysql/mysql-log.log had been rotated
 - Actually, there was no "mysql-log.*" in /var/lib/mysql/, only the original file /var/lib/mysql/mysql-log.log, as big as before executing the command ...
 
I give you now my onfig files, and the extract of the logs produced my the command logrotate that concerns mysql.
/etc/logrotate.conf
# see "man logrotate" for details # rotate log files weekly weekly # keep 4 weeks worth of backlogs rotate 4 # create new (empty) log files after rotating old ones create # uncomment this if you want your log files compressed #compress # RPM packages drop log rotation information into this directory include /etc/logrotate.d # no packages own wtmp -- we'll rotate them here /var/log/wtmp { monthly minsize 1M create 0664 root utmp rotate 1 } # system-specific logs may be also be configured here.  /etc/logrotate.d/mysql
/var/lib/mysql/mysql-log.log { rotate 4 daily nocompress missingok create 660 mysql mysql postrotate if ls /proc/`cat /var/run/mysqld/mysqld.pid` > /dev/null then /usr/bin/mysqladmin -pMotDePasseSqlRoot flush-logs fi endscript }  And here is the logrotate logs I noted concerning mysql :
reading config file mysql reading config info for /var/lib/mysql/mysql-log.log ... rotating pattern: /var/lib/mysql/mysql-log.log forced from command line (4 rotations) empty log files are rotated, old logs are removed considering log /var/lib/mysql/mysql-log.log log needs rotating rotating log /var/lib/mysql/mysql-log.log, log->rotateCount is 4 renaming /var/lib/mysql/mysql-log.log.4 to /var/lib/mysql/mysql-log.log.5 (rotatecount 4, logstart 1, i 4), renaming /var/lib/mysql/mysql-log.log.3 to /var/lib/mysql/mysql-log.log.4 (rotatecount 4, logstart 1, i 3), renaming /var/lib/mysql/mysql-log.log.2 to /var/lib/mysql/mysql-log.log.3 (rotatecount 4, logstart 1, i 2), renaming /var/lib/mysql/mysql-log.log.1 to /var/lib/mysql/mysql-log.log.2 (rotatecount 4, logstart 1, i 1), renaming /var/lib/mysql/mysql-log.log.0 to /var/lib/mysql/mysql-log.log.1 (rotatecount 4, logstart 1, i 0), renaming /var/lib/mysql/mysql-log.log to /var/lib/mysql/mysql-log.log.1 creating new log mode = 0660 uid = 27 gid = 27 running postrotate script running script with arg /var/lib/mysql/mysql-log.log : " if ls /proc/`cat /var/run/mysqld/mysqld.pid` > /dev/null then /usr/bin/mysqladmin -pMotDePasseSqlRoot flush-logs fi " removing old log /var/lib/mysql/mysql-log.log.5  Do you have any idea why logrotates reports about an action it doesn't actuallay do ? Did I miss a step before or after defining my file /etc/logrotated.d/mysql ?
Thanks for your help !
Sylvain