1

I have setup log rotation for postfix with a logrotate config file as follows:

/var/log/mail.*
{
        rotate 7
        daily
        missingok
        notifempty
        delaycompress
        compress
}

But the files are rotating strangely. For example, here is an excerpt of the mail log files I see:

-rw-r-----  1 syslog  adm            0 Jan 10 01:47 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.2.gz
-rw-r-----  1 syslog  adm            0 Jan 11 02:04 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.2.gz.1
-rw-r-----  1 syslog  adm            0 Jan 11 02:04 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.2.gz.1.1
-rw-r-----  1 syslog  adm            0 Jan 19 01:48 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.2.gz.1.1.1
-rw-r-----  1 syslog  adm            0 Jan 21 01:59 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.2.gz.1.1.1.1
-rw-r-----  1 syslog  adm            0 Jan 23 02:16 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.2.gz.1.1.1.1.1
-rw-r-----  1 syslog  adm            0 Jan 28 02:39 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.2.gz.1.1.1.1.1.1
-rw-r-----  1 syslog  adm           20 Jan  8 01:36 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.2.gz.1.1.1.1.1.1.1
-rw-r-----  1 syslog  adm            0 Jan  5 01:28 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.2.gz.1.2.gz
-rw-r-----  1 syslog  adm            0 Jan  9 01:44 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.2.gz.2.gz
-rw-r-----  1 syslog  adm            0 Jan 10 01:47 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.3.gz
-rw-r-----  1 syslog  adm            0 Jan  7 01:32 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.3.gz.1
-rw-r-----  1 syslog  adm            0 Jan 11 02:04 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.4.gz
-rw-r-----  1 syslog  adm            0 Jan  9 01:44 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.4.gz.1
-rw-r-----  1 syslog  adm            0 Jan 19 01:48 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.5.gz
-rw-r-----  1 syslog  adm            0 Jan 21 01:59 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.5.gz.1
-rw-r-----  1 syslog  adm            0 Jan 23 02:16 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.5.gz.1.1
-rw-r-----  1 syslog  adm            0 Jan 28 02:39 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.5.gz.1.1.1
-rw-r-----  1 syslog  adm           33 Dec 31 01:25 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.5.gz.1.1.1.1
-rw-r-----  1 syslog  adm            0 Jan  9 01:44 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz
-rw-r-----  1 syslog  adm            0 Jan 10 01:47 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1
-rw-r-----  1 syslog  adm            0 Jan 10 01:47 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.1
-rw-r-----  1 syslog  adm            0 Jan 12 02:26 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.1.1
-rw-r-----  1 syslog  adm            0 Jan 20 01:51 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.1.1.1
-rw-r-----  1 syslog  adm            0 Jan 22 02:06 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.1.1.1.1
-rw-r-----  1 syslog  adm            0 Jan 24 02:26 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.1.1.1.1.1
-rw-r-----  1 syslog  adm           20 Jan  7 01:32 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.1.1.1.1.1.1
-rw-r-----  1 syslog  adm            0 Jan  5 01:28 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.2.gz
-rw-r-----  1 syslog  adm            0 Jan 11 02:04 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz
-rw-r-----  1 syslog  adm            0 Jan 19 01:48 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1
-rw-r-----  1 syslog  adm            0 Jan 21 01:59 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.1
-rw-r-----  1 syslog  adm            0 Jan 23 02:16 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.1.1
-rw-r-----  1 syslog  adm            0 Jan 28 02:39 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.1.1.1
-rw-r-----  1 syslog  adm           20 Jan  8 01:36 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.1.1.1.1.1
-rw-r-----  1 syslog  adm            0 Jan  9 01:44 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.3.gz
-rw-r-----  1 syslog  adm            0 Jan  6 01:29 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.3.gz.1
-rw-r-----  1 syslog  adm            0 Jan 10 01:47 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.4.gz
-rw-r-----  1 syslog  adm            0 Jan  8 01:36 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.4.gz.1
-rw-r-----  1 syslog  adm            0 Jan 12 02:26 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.5.gz
-rw-r-----  1 syslog  adm            0 Jan 20 01:51 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.5.gz.1
-rw-r-----  1 syslog  adm            0 Jan 22 02:06 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.5.gz.1.1
-rw-r-----  1 syslog  adm            0 Jan 24 02:26 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.5.gz.1.1.1
-rw-r-----  1 syslog  adm           20 Jan  3 01:26 mail.log.7.gz.2.gz.2.gz.2.gz.2.gz.2.gz.2.gz.5.gz.1.1.1.1

Can someone explain what's wrong / what I need to add to my logrotate config file for postfix to correct this?

2

/var/log/mail.* matches all files starting with mail. including files that have already been rorated...

The only file that actually needs rotating is the current log file so please use /var/log/mail.log instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.