我有默认的 Debian 8.5 Jessie/etc/logrotate.conf
内容:
# see "man logrotate" for details
# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
rotate 4
# create new (empty) log files after rotating old ones
create
# uncomment this if you want your log files compressed
#compress
# packages drop log rotation information into this directory
include /etc/logrotate.d
# no packages own wtmp, or btmp -- we'll rotate them here
/var/log/wtmp {
missingok
monthly
create 0664 root utmp
rotate 1
}
/var/log/btmp {
missingok
monthly
create 0660 root utmp
rotate 1
}
# system-specific logs may be configured here
通过此设置logrotate
可以很好地完成其工作。但是,如果我改变:
rotate 4
到不同的东西,例如:
rotate 5
logrotate
它永远不会完成它的工作,消耗所有的 CPU 能力,所以我最终不得不终止它的进程。
这是为什么?调整时我应该改变一些东西吗rotate
?
答案1
尝试寻找一些命令来解析/调试 logrotate 配置而不实际应用它。
从man 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.
使用你会运行
logrotate -d /etc/logrotate.conf