Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
What mail system do you use? – Kazimieras Aliulis May 12 '09 at 15:39
up vote 8 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)


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/ /var/log/mail.warn /var/log/mail.err {
        rotate 7
        create 640 root adm
           /etc/init.d/sysklogd reload

To check your configuration, run:

logrotate -d /etc/logrotate.conf

And verify that logrotate is doing what you want.

share|improve this answer
Perfect - exactly what I need - thank yoU! – Brent May 12 '09 at 16:11
Just an update for Debian wheezy. The settings for the mail logs are not in the sysklogd file anymore. The settings moved to /etc/logrotate.d/rsyslog. Just remove the lines that point to the mail logs and add them into a new file as described by MikeyB. Also the logrotate man files are pretty helpful – fabiantheblind Jan 13 at 8:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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