logrotate 不会自动旋转我的日志

fab*_*rik 9 debian logrotate debian-squeeze

我有两个不同的 (i386 v AMD) Debian 机器并且有同样的问题。logrotate 不会自动旋转我的日志。当我手动强制它时它工作正常

/usr/sbin/logrotate -f /etc/logrotate.conf

但这对我来说不好。

设置没有修改(至少我没有修改它们),AMD 盒子是全新安装的,但不能完成它的工作。

如果您注意到类似的问题,请帮助我。

更新(一些服务器输出):

logrotate -d http://pastebin.com/e6AshtGq

ls -l /var/log http://pastebin.com/Y2A4Li59

cat /etc/logrotate.conf http://pastebin.com/1h7Uwctr

ls -l /etc/logrotate.d http://pastebin.com/NvUAeszM

小智 10

我有一个类似的问题,但crontab正在工作,并且对于某些日志目录logrotate有效,但对于某些没有。当我尝试手动运行 logrotate 时,我收到了一些错误消息。

user@server:/var/log/apache2$ sudo /usr/sbin/logrotate -f /etc/logrotate.conf
error: error creating output file /var/log/apache2/access.log.1.gz: File exists
error: error creating output file /var/log/apache2/error.log.1.gz: File exists
...
Run Code Online (Sandbox Code Playgroud)

所有*.1.gz文件的大小都为 0。我手动删除了错误消息中提到的所有文件,sudo /usr/sbin/logrotate -f /etc/logrotate.conf再次运行并成功。

我只是虽然我也应该在这里分享这个替代解决方案,因为这是我搜索问题时出现的第一个搜索结果,但建议的解决方案对我不起作用。也许这也有助于其他与我处于相同情况的人。


use*_*517 8

检查您的 logrotate 是否由 cron 运行。

编辑:

从评论讨论中 - 似乎 cron 无法正常工作。我的 crontab 中有一个没有用户的 cronjob,但只有在我重新启动 cron 守护进程时才会出现

我的 ubuntu 和 centos 系统有一个/etc/cron.daily/logrotate文件,其内容是

#!/bin/sh

test -x /usr/sbin/logrotate || exit 0
/usr/sbin/logrotate /etc/logrotate.conf
Run Code Online (Sandbox Code Playgroud)

我的 /etc/crontab 有以下行来运行日常工作

25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily 
Run Code Online (Sandbox Code Playgroud)