If a logrotate config is specified with "size" and "daily" parameters, which one takes precedence? Where is this documented? I would like these rotations to occur as a boolean OR operation, ie, if the logs are a day old they get rotated, OR if they are larger than a certain size they will also get rotated. However, logrotate is currently only using the "size" directive, and appears to be ignoring the "daily" directive. Logrotate is set up to run every hour. OS is linux, Red Hat and Debian derivatives.

Also, I am specifying "daily" first, then "size" from the start of the file. Not sure if the order matters, but in any case, one has to come first in the config file...



4 Answers 4


If the size directive is used, logrotate will ignore the daily, weekly, monthly, and yearly directives. This is not clear in the documentation when you execute the man logrotate command. However it can be confirmed in practice, and is mentioned in some arbitrary blog posts such as this one.

There is a directive called minsize which according to the logrotate man page is the only size directive that can be used in conjunction with the time ones. However, its still not what you want. Using minsize with daily essentially says: rotate the logs daily, but only when they are at least #MB in size.

To date I have found no way with logrotate to do the condition you require: rotate every day, unless the size exceeds #MB, in which case rotate immediately. I do not think this is supported using only logrotate directives. It might be possible to do with some clever scripting via the script hook directives like prerotate, postrotate, firstaction, and lastaction.


As of logrotate 3.8.1, maxsize and timeperiod are supported together, which would be the ideal solution. See the answer to this post: How to rotate log based on an interval unless log exceeds a certain size?

  • 4
    Best option would probably be to use two separate cron commands, run to run it daily with the default conf, and one every x minutes that takes a config with just the files that you worry about overflow using the size directive and not the daily. Nov 28, 2012 at 2:11
  • 8
    As of logrotate 3.8.1, maxsize and timeperiod are supported. Per serverfault.com/questions/474941/…
    – belacqua
    Jul 3, 2013 at 17:31
  • 1
    @belacqua I am using 3.8.7 and timeperiod is not in the man.
    – JorgeeFG
    Jan 21, 2015 at 16:22
  • The correct version is actually 3.8.1, not 3.81.
    – Tom Miller
    Jun 19, 2018 at 21:52

The first answer by @egg is, according to my experiences with logrotate, not true!

If daily, monthly, ... come first and after that size directive, daily, monthly, ... will be ignored and size directive will apply to the log file.

Similarly when I first use the size directive then daily, weekly, monthly, and yearly directives, the size directive will be ignored.

  • And the daily, monthly, ... and size must come before directive include /path/of/logrotate.d/ to take effect for each specific log file configured in /path/of/logrotate.d/.
    – Bruce
    Sep 8, 2022 at 18:17

If you add Daily it is going to rotate each day even if the Size condition is met. If you add the size condition as well you may get two rotations in one day depending on how verbose the logging is.

If Daily goes first in the script then Size may not fire off.

  • use the verbose option to see which rules are used. From my tests I believe only the last rule is used because more specific rules can override more general rules.
    – Bram
    May 22, 2012 at 19:18
  • More rotations are OK, as that would be the expected behavior. (boolean OR) However, my issue is that these rotations are not occurring. It appears to be a bug (possibly a feature) of log rotate, as I can not see the order of directives being important or documented anywhere.
    – cat pants
    May 22, 2012 at 23:15
  • can you give an example of your logrotate.conf and the files you are trying to target? Daily does not have a condition other then time progression. Size is conditional. May 23, 2012 at 13:01
  • /tmp/output.log { daily size 1k rotate 5 }
    – cat pants
    Jun 19, 2012 at 17:39
  • 1
    This file gets rotated when the size is greater than 1k, but it is not rotated daily as expected and desired.
    – cat pants
    Jun 19, 2012 at 17:40

Actually, my man page on Red Hat appears to be pretty clear on the differences between size and 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 with-
          out regard for the last rotation time.  When minsize is  used,
          both the size and timestamp of a log file are considered.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .