根据手册页:
rotate *count*
Log files are rotated count times before being removed or mailed to the address specified
in a mail directive. If count is 0, old versions are removed rather than rotated. Default
is 0.
如果您不设置此值,则默认为零,这意味着它会删除它轮换出的所有内容。您可以从调试转储中看到这一点,首先使用我现有的配置(旋转 4):
rotating pattern: /var/log/boot.log
after 1 days (7 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/boot.log
log does not need rotating (log is empty)
rotating pattern: /var/log/chrony/*.log weekly **(4 rotations)**
当我注释掉那一行并将它留在任何地方未定义时:
rotating pattern: /var/log/boot.log
after 1 days (7 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/boot.log
log does not need rotating (log is empty)
rotating pattern: /var/log/chrony/*.log weekly **(no old logs will be kept)**
logrotate 的主要用途之一是管理日志占用的空间量;让它旋转到无穷大而不移除任何东西违背了这个目的。您也没有发布您的实际配置文件,所以我不知道您要旋转的其他参数是什么。
如果您每天轮换多次,我的主要建议是定期将那些已经轮换的日志移出该目录,以便 logrotate 不再考虑它们。这样,您的配置就会变得简单得多。