所以这让我发疯了。我每周都会运行logrotate来获取一些不同的日志,它可以按照我的预期运行。但是,日志轮换发生在星期日,这与完成某些处理相同,这些处理记录到要旋转的目录。简而言之,我想在星期四之前轮换这些日志文件,在此处理之前,我想在logrotate配置中保持“修复”(副手动运行logrotate --force,或将其置于脚本中) )。
我正在使用以下配置运行RHEL5:
cat /etc/logrotate.d/custom
/var/log/mpxx/mpxx_log {
daily
rotate 30
compress
missingok
olddir /var/log/mpxx.old/
create 644 user user
dateext
}
/var/log/mpxx/repo.log /var/log/mpxx/stop_repo.log {
weekly
rotate 90
compress
missingok
olddir /var/log/mpxx.old/
create 644 user user
dateext
}
cat /var/lib/logrotate.status
"/var/log/mpxx/repo.log" 2015-4-12
"/var/log/mpxx/stop_repo.log" 2015-4-12
我在4月10日周五用logrotate --force /etc/logrotate.d/custom手动旋转了日志,当时我注意到了这个问题。然后,我手动编辑了logrotate.status文件以反映以下内容:
"/var/log/mpxx/repo.log" 2015-4-9
"/var/log/mpxx/stop_repo.log" 2015-4-9
不幸的是,我手动运行logrotate,并且我对状态文件的编辑并没有让logrotate在4月12日不再旋转日志文件,如前所述。
如何强制logrotate每周执行轮换,但是在一周的特定日期?我的搜索和研究没有多少出现。
提前致谢!
答案 0 :(得分:0)
我知道这已经很老了,但是我自己不得不执行类似的事情,发现了这个问题并认为我会回答。
logrotate(8)
具有此内置功能:
weekly [weekday]
Log files are rotated once each weekday, or if the date is advanced by at least 7 days since the last rotation (while ignoring the exact time). The weekday interpretation is following: 0
means Sunday, 1 means Monday, ..., 6 means Saturday; the special value 7 means each 7 days, irrespectively of weekday. Defaults to 0 if the weekday argument is omitted.