2

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?

1

1 Answer 1

9

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.

1
  • 2
    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 Jan 13, 2016 at 8:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .