up vote 0 down vote favorite
share [g+] share [fb]

Mail Logs on Debian systems do not use the regular /etc/logrotate.d scripts to rotate them.

I want to force my mail logs to rotate daily (no matter how small), and compress the results, so that the numbering of the logfiles matches that of my other (busier) mail servers. Essentially, I want to end up with:

mail.log mail.log.0 mail.log.1.gz mail.log.2.gz ... mail.log.6.gz

Can someone tell me how to accomplish this?

link|improve this question

76% accept rate
1  
What mail system do you use? – Kz. May 12 '09 at 15:39
feedback

1 Answer

up vote 6 down vote accepted

I'm presuming that at the moment you have the stock sysklogd installation and that your logfiles are rotated with the default /etc/cron.weekly/sysklogd script.

I would suggest that you edit /etc/cron.weekly/sysklogd script and modify:

logs=$(syslogd-listfiles --weekly)

to:

logs=$(syslogd-listfiles --weekly -s mail\*)

This will prevent the default scripts from handling the mail logs.

Edit /etc/logrotate.d/sendmail and add entries for the appropriate files. You probably want something like:

/var/log/mail.log /var/log/mail.info /var/log/mail.warn /var/log/mail.err {
        rotate 7
        daily
        compress
        delaycompress
        missingok
        create 640 root adm
        sharedscripts
        postrotate
           /etc/init.d/sysklogd reload
        endscript
}

To check your configuration, run:

logrotate -d /etc/logrotate.conf

And verify that logrotate is doing what you want.

link|improve this answer
Perfect - exactly what I need - thank yoU! – Brent May 12 '09 at 16:11
feedback

Your Answer

 
or
required, but never shown

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