4

I have the following setup: removed the line contaning /var/log/maillog from /etc/logrotate.d/syslog file, and added the following in /etc/logrotate.conf file:

...

# system-specific logs may be also be configured here.

/var/log/maillog
{
    missingok
    notifempty
    nocompress
    size=50k
    postrotate
        touch /var/log/maillog
    endscript
}

Why does the touch /var/log/maillog line never get executed when the file size reaches 50k?

Jay
  • 347
  • 2
  • 5
  • 10
  • What do you see for that file if you run `logrotate -d /etc/logrotate.conf`? – Etan Reisner Dec 10 '14 at 10:45
  • ... `reading config info for /var/log/maillog` ... `rotating pattern: /var/log/maillog 51200 bytes (10 rotations) empty log files are not rotated, old logs are removed considering log /var/log/maillog log needs rotating rotating log /var/log/maillog, log->rotateCount is 10 dateext suffix '-20141210' glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' destination /var/log/maillog-20141210 already exists, skipping rotation` – Jay Dec 10 '14 at 10:55
  • That last line seems like the key here I would think. `destination /var/log/maillog-20141210 already exists, skipping rotation` I'm not sure how that's supposed to work with date extensions. – Etan Reisner Dec 10 '14 at 12:52

1 Answers1

5

Because it is possible to get multiple rotations within the day when using size bound rotation it's not logical to use dateext option. From your comment showing the result of logrotate -d /etc/logrotate.conf, it looks like it is enabled.

You can disable dateext in the block by adding nodateext option. Now the config will be:

...

# system-specific logs may be also be configured here.

/var/log/maillog
{
    missingok
    notifempty
    nocompress
    size=50k
    nodateext ## ADD THIS LINE ##
    postrotate
        touch /var/log/maillog
    endscript
}
oradwell
  • 392
  • 1
  • 12