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

Ada*_*tan 3 logrotate

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

"/var/log/uwsgi/*/*.log" {
  ...
  size 400M
  daily  rotate 14
  ..
}
Run Code Online (Sandbox Code Playgroud)

但是,即使在日志文件大小超过 400M 时执行 logrotate,也不会进行任何轮换。

知道如何在任一条件下强制旋转吗?

mur*_*uru 6

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.
Run Code Online (Sandbox Code Playgroud)