![Logrotate:使用多个标准进行旋转](https://linux22.com/image/1122879/Logrotate%EF%BC%9A%E4%BD%BF%E7%94%A8%E5%A4%9A%E4%B8%AA%E6%A0%87%E5%87%86%E8%BF%9B%E8%A1%8C%E6%97%8B%E8%BD%AC.png)
如何根据大小和频率标准的分离来设置轮换策略。我尝试了以下方法:
"/var/log/uwsgi/*/*.log" {
...
size 400M
daily rotate 14
..
}
但是,即使在日志文件大小超过 400M 时执行 logrotate,也不会进行轮换。
知道如何在任一条件下强制旋转吗?
答案1
size
与基于时间的设置不兼容,因此当您在daily
其后指定时,它将被否决。尝试maxsize
。从man logrotate
:
maxsize size
Log files are rotated when they grow bigger than size bytes even
before the additionally specified time interval (daily, weekly,
monthly, or yearly). The related size option is similar except
that it is mutually exclusive with the time interval options,
and it causes log files to be rotated without regard for the
last rotation time.