logrotate没有旋转我的日志
验证日志文件是否为空:
# ls -laFh /var/log/cisco-meraki.log
-rw-r----- 1 root adm 2.8G Sep 5 13:23 /var/log/cisco-meraki.log
配置(/etc/logrotate.d/zzzzz_default):
"/var/log/cisco-meraki.log" {
daily
rotate 10
compress
missingok
notifempty
create
}
全局配置(logrotate.conf):
daily
rotate 10
create
include /etc/logrotate.d
/var/log/wtmp {
missingok
monthly
create 0664 root utmp
rotate 1
}
/var/log/btmp {
missingok
monthly
create 0660 root utmp
rotate 1
}
尝试手动运行:
# logrotate --verbose -d zzzzz_default
reading config file zzzzz_default
Handling 1 logs
rotating pattern: "/var/log/cisco-meraki.log" after 1 days (10 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/cisco-meraki.log
log does not need rotating
为了确认问题没有“全部轮换”,我检查了一下:
# cat /var/lib/logrotate/status|grep cisco
"/var/log/cisco-ace.log" 2016-1-19-16:0:0
"/var/log/cisco-pix.log" 2016-1-19-16:0:0
"/var/log/cisco-acs.log" 2016-1-19-16:0:0
"/var/log/cisco-asa.log" 2016-1-19-16:0:0
"/var/log/cisco-router.log" 2016-9-6-0:1:1
"/var/log/cisco-ips.log" 2016-1-19-16:0:0
..但没有cisco-meraki.log
答案 0 :(得分:2)
从logrotate手册页:
-d, --debug
Turns on debug mode and implies -v. In debug mode, no
changes will be made to the logs or to the logrotate
state file.
我遇到了完全相同的问题!
<磷>氮答案 1 :(得分:1)
请参阅https://unix.stackexchange.com/a/96947
假设您今天创建了zzzzz_default文件。 logrotate将在/ var / lib / logrotate / status中创建一个条目,就像它今天轮换日志一样。
今天运行logrotate --verbose -d zzzzz_default
logrotate检查它最后一次旋转日志读取/ var / lib / logrotate / status。它会找到之前创建的条目,因此它会说log does not need rotating
如果您明天开始logrotate --verbose -d zzzzz_default
logrotate检查它最后一次旋转日志读取/ var / lib / logrotate / status。 不会找到该条目,因此它会旋转日志文件。