我有此logrotate配置,并且我在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
}
我昨天将其放在/etc/logrotate.d中,今天日志没有旋转。
以下是我所做的事情:
- 我验证了日志确实在/var/log/mysql/mysql-slow.log中
- 以root用户身份运行时,mysqladmin行工作正常
- mysql能够写入mysql-slow.log
当我这样做时:
$ 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
- 显示logrotate成功的日志在哪里?我想看看是否有什么问题。
- 关于为什么logrotate不起作用的任何想法?
mysql-server
吧?运行grep '/var/log/mysql' /etc/logrotate.d/*
。
/etc/crontab
文件中以结尾的行中找到该信息/etc/cron.daily )
。也许您已经在当天的cron日常作业运行后创建了logrotate配置?
crond
跑步吗?