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?


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/mail.info /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.

| improve this answer | |
  • 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 linux.die.net/man/8/logrotate – fabianmoronzirfas Jan 13 '16 at 8:26

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.