Logrotate:使用多个标准进行旋转

Logrotate:使用多个标准进行旋转

如何根据大小和频率标准的分离来设置轮换策略。我尝试了以下方法:

"/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.

相关内容