在最后几天,我从cron的logrotate任务获得每日邮件:
/etc/cron.daily/logrotate:
gzip:stdin:压缩时文件大小已更改
我该如何解决?
谢谢, 吉安马可。
答案 0 :(得分:23)
这是a blog post in French提供解决方案。
在英语中,您可以阅读this bug report。
总结:
首先,您必须在脚本--verbose
中添加/etc/cron.daily/logrotate
选项,以便在下次运行时获取更多信息,以确定哪个轮换日志会导致问题。
#!/bin/sh
test -x /usr/sbin/logrotate || exit 0
/usr/sbin/logrotate --verbose /etc/logrotate.conf`
接下来,您必须在logrotate配置中添加delaycompress
选项。
答案 1 :(得分:1)
upstart
将在it notices that the file is deleted时关闭(并重新打开)其日志文件。但是,如果查看what gzip does,您会看到它在写入输出文件之前不会删除该文件。这意味着始终存在一种竞争条件,即在写入行{1}}的行日志时可能会丢失日志行。
您可以使用gzipping
禁用警告,但实际上并不能隐藏您可能仍然松散日志行的事实。
这意味着gzip --quiet
不是对此的通用修复。这是针对特定问题的具体方法。
对此的真正解决方案可能是delaycompress
的组合,并且能够向流程发送信号。这将使比赛条件在实践中消失(除非你每秒旋转多次:))。