问题已解决,但我正在写下以供将来参考。
/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
从命令行运行时运行正常:
# logrotate -v -f /etc/logrotate.d/mysql
但是在凌晨4点从cron运行时,它不起作用日志文件已旋转,但MySQL不会将错误记录到新创建的文件中:
-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