我有一个日志文件,我的服务使得文件名为“Feed1 – 1.stat”。 logrotate拒绝旋转此文件,但只有在通过cron运行时 。 通过shell运行logrotate将正确地旋转文件。 更改configuration和日志文件没有空格也会导致文件正确旋转。
下面是剧本脚本的相关部分:
"/opt/myservice/statistics/continuous/Feed1 - 1.stat" { rotate 60 daily missingok notifempty compress delaycompress postrotate /usr/bin/killall -HUP myservice endscript }
这里是启动logrotate的cron条目(Ubuntu默认):
#!/bin/sh # Clean non existent log file entries from status file cd /var/lib/logrotate head -1 status > status.clean sed 's/"//g' status | while read logfile date do [ -e "$logfile" ] && echo "\"$logfile\" $date" done >> status.clean mv status.clean status test -x /usr/sbin/logrotate || exit 0 /usr/sbin/logrotate /etc/logrotate.conf
我怀疑可能与环境variables有关的东西? 我可以看到cron环境相当稀疏,但不知道如何从这里进行debugging。
有任何想法吗? 谢谢 :-)
Ubuntu 11.04 Natty 64位
2.6.38-8服务器
logrotate 3.7.8-6ubuntu3.1
编辑:
Ubuntu logrotate cron脚本被破坏,并从状态文件中去掉双引号。 然后检查文件是否存在,哪些不是因为引号不存在而删除该行。 然后logrotate重新添加执行中的行,但它刚刚添加它,不旋转。 无限广告。
我将在Launchpad上提交一个错误。
编辑:inheritance人的错误报告: https : //bugs.launchpad.net/ubuntu/+source/logrotate/+bug/932225
这听起来像权限问题。 你检查过吗? {我想在控制台中执行lograte作为root}
除此之外,只要提到你可以随时按尺寸旋转它。