如果我运行 logrotate 我会得到log does not need rotating (log has been already rotated)
并且日志文件不会旋转。为什么?
我的日志旋转配置:
/var/log/capp/*.log {
missingok
rotate 90
daily
notifempty
compress
delaycompress
}
在我运行 logrotate 之前,我删除了该行
"/var/log/capp/server.log" 2019-4-1-7:0:0
从文件/var/lib/logrotate/logrotate.status
日志旋转输出:
/> logrotate -v /etc/logrotate.d/capp
reading config file /etc/logrotate.d/capp
Allocating hash table for state file, size 15360 B
Handling 1 logs
rotating pattern: /var/log/capp/*.log after 1 days (90 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/capp/server.log
log does not need rotating (log has been already rotated)
并且日志文件不旋转:
/> ls -la /var/log/capp/server.log*
-rw-r--r-- 1 capp capp 272962507 1. Apr 07:00 /var/log/capp/server.log
可能 logrotate 只会在第二次运行时开始轮换日志文件。似乎如果该文件的条目
/var/lib/logrotate/logrotate.status
不在 logrotate 中,则不会旋转该文件。所以诀窍是让我改变/var/lib/logrotate/logrotate.status
路线至
... 并且 logrotate 开始旋转
server.log
文件