Log file rotation

Alf-Ivar Holm alfh at student.matnat.uio.no
Tue Sep 12 15:48:51 UTC 2006

Damien Hull <dhull at digitaloverload.net> writes:

> I've got Ubuntu Dapper installed and configured as a mail server. I'm 
> using Postfix as the MTA. My problem is with /var/log/mail.log. I would 
> like to keep the log file for a week and then have it rotate. However, 
> this isn't happening. It seems to be rotating when it wants to.

I can confirm this on a production postfix box, but on that box it is
happening daily.

> I've checked /etc/cron.weekly and sysklogd is there. I ran the command 
> to list the files that will be rotated and mail.log is in the list.
> I have a test server with the same setup. It's only a test server so it 
> doesn't get any mail. The strange thing is that /var/log/mail rotates 
> once a week. Not mid week or when ever it wants like our production server.
> Can someone tell me what's going on here? Again, I want /var/log/mail to 
> rotate once a week.

"syslogd-listfiles --wekly" in /etc/cron.weekly/sysklogd do indeed
list mail.log, and "syslogd-listfiles" in /etc/cron.daily/sysklogd
does not, but the files are rotated daily:

-rw-r----- 1 root adm  573570 2006-09-12 17:19 /var/log/mail.log
-rw-r----- 1 root adm 1488772 2006-09-12 07:34 /var/log/mail.log.0
-rw-r----- 1 root adm  159406 2006-09-11 07:34 /var/log/mail.log.1.gz
-rw-r----- 1 root adm  162050 2006-09-10 07:35 /var/log/mail.log.2.gz
-rw-r----- 1 root adm  171830 2006-09-09 07:36 /var/log/mail.log.3.gz
-rw-r----- 1 root adm  227025 2006-09-08 07:35 /var/log/mail.log.4.gz
-rw-r----- 1 root adm  189718 2006-09-07 07:35 /var/log/mail.log.5.gz
-rw-r----- 1 root adm  195539 2006-09-06 07:33 /var/log/mail.log.6.gz

Another clue that the daily script is run is that the weekly cron file
only rotates 4 times, while the daily cron file does it 7 times.  It
is also probably done by savelog(8), as that starts the rotation at 0,
while the logrotate(8) files seems to start at 1 (even though
logrotate supports starting at 0).

The only thing I can guess at is that there is some space limit
triggering the rotation as your server is not doing it every day (as I
understand you), and "syslogd-listfiles --large" list the mail.log
above, but I don't see that the --large flag is used in any script.


More information about the ubuntu-users mailing list