Bug 12155

Summary: Mail log file is not rotated
Product: IPFire Reporter: Tim <ipfb>
Component: ---Assignee: Matthias Fischer <matthias.fischer>
Status: CLOSED FIXED QA Contact:
Severity: Minor Usability    
Priority: Will only affect a few users CC: michael.tremer, peter.mueller
Version: 2   
Hardware: all   
OS: All   

Description Tim 2019-09-03 17:10:29 UTC
syslogd is set up to send mail log messages to /var/log/mail, however logrotate is not set up to rotate this file.

While the default system does not send mail messages, there are addons (such as WIO) that do.  This can lead to this file growing without restriction.  This file should either be rotated or merged back into the default log.

For information my log file is over 550KB.
Comment 1 Michael Tremer 2019-09-05 09:44:21 UTC
Matthias, could you have a look at this?
Comment 2 Matthias Fischer 2019-09-07 09:46:29 UTC
What about this in '/etc/logrotate.conf'?

/var/log/mail.log {
    weekly
    rotate 4
    copytruncate
    compress
    notifempty
    missingok
}
Comment 3 Michael Tremer 2019-09-09 10:42:15 UTC
That should do it. Did you test it?
Comment 4 Matthias Fischer 2019-09-09 17:54:50 UTC
Yes. I'm testing and waiting for the next rotation.
Comment 5 Tim 2019-09-14 16:25:37 UTC
/var/log/mail is an output from syslogd, so wouldn't it be preferable to add the file to the existing list of syslogd output files rather than creating it's own entry?  That would save any problems due to lack of synchronisation with syslogd being sent the HUP signal.

I'm not sure whether there would be any problems in practice, but it's possible that mail log messages could go missing if they're written after the mail log is rotated but before syslogd receives it's HUP - they could still be written to the old mail log file which will syslogd will still have open. They will then be deleted when sylogd receives the HUP.

(Note: in case it's not clear, the 550KB in my original report refers to the size of my mail log file).
Comment 6 Matthias Fischer 2019-09-15 07:18:29 UTC
I tested:

/var/log/mail {
    weekly
    rotate 4
    copytruncate
    compress
    notifempty
    missingok
}

Worked.

But I'm not using 'Mail Service', so there are not much entries and nearly nothing to rotate.

@Tim (your case is clear):

If I get you right, the alternative would be to add '/var/log/mail' like this:

/var/log/messages /var/log/bootlog /var/log/dhcpcd.log /var/log/mail {
    create 664 root syslogd
    sharedscripts
    ifempty
    postrotate
/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
}

Done. Testing... ;-)

Any opinions?
Comment 7 Michael Tremer 2019-09-15 10:41:44 UTC
I guess Tim’s suggestion would work...
Comment 8 Tim 2019-09-19 18:23:10 UTC
Matthias,

That alternative is what I was thinking of.  It would be my preference.