Problem solved but I'm writing down for the future reference.
/root/.my.cnf
[mysqladmin]
user = root
password = pa$$w0rd
/etc/logrotate.d/mysql
/var/log/mysql-slow.log /var/log/mysqld.log {
daily
rotate 7
dateext
compress
missingok
#notifempty
sharedscripts
create 644 mysql mysql
postrotate
/usr/bin/mysqladmin flush-logs
endscript
}
logrotate
is working fine when running from the command line:
# logrotate -v -f /etc/logrotate.d/mysql
but it doesn't work when running from cron at 4 A.M. The logs file was rotated but MySQL doesn't logs the error to newly created file:
-rw-r--r-- 1 mysql mysql 0 Aug 7 10:13 /var/log/mysqld.log
-rw-r--r-- 1 mysql mysql 20 Aug 4 04:04 /var/log/mysqld.log-20120804.gz
-rw-r--r-- 1 mysql mysql 20 Aug 5 04:04 /var/log/mysqld.log-20120805.gz
-rw-r--r-- 1 mysql mysql 20 Aug 6 16:28 /var/log/mysqld.log-20120806.gz