23
19

More than 5 years have passed since last update.

logrotate の size と minsize の違い

Last updated at Posted at 2013-05-27

簡単にまとめると

  • minsize は and による条件の追加
  • size は or による条件の追加

man から引用

minsize


minsize size
  Log  files  are  rotated  when they grow bigger then size bytes, but not 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.  When minsize is used, both the size and timestamp of a log 
  file are considered.

minsize は ローテーションの周期を示すオプション(daily, weekly, monthly, yearly) と同時に指定した場合、logrotateコマンドを実行した時点でその周期を経過している場合かつ、minsize で指定したサイズを超えていたときにローテーションを実行する。

たとえば、weekly と minsize 1M の両方を指定している場合、前回のローテーションから1週間以上経過しており、かつ、そのときファイルの容量が 1M を超えていればローテーションされる。

size


size size
  Log  files  are rotated only if they grow bigger then size bytes. If size is
  followed by M, the size if assumed to be in megabytes.  If the k is used, the size
  is in kilobytes. So size 100, size 100k, and size 100M are all valid.

一方、size を指定した場合は、ローテーション周期を経過していることまたは、ファイルの容量が size で指定したサイズを超えていればローテーションされる。

つまり、weekly と size 1M の両方を指定している場合、1週間が経過する前にファイルの容量が1Mを超えた場合、そこでローテーションが行なわれるし、前回のローテーションから1週間経過した時ファイルサイズが1M以下でもローテーションされる。

参考

logrotate daily and size?
http://serverfault.com/questions/391538/logrotate-daily-and-size

23
19
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23
19