Topic: mail.log not rotated correctly in iRedMail on Debian 11
==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 1.5.1
- Deployed with iRedMail Easy or the downloadable installer? Downloadable
- Linux/BSD distribution name and version: Debian 11
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MariaDB
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? No
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====
I've noticed that iRedMail on Debian 11 doesn't rotate /var/log/mail.log correctly.
mail.log is rotated to mail.log.1 and mail.log is created, but postfix continues to append to mail.log.1, leaving mail.log empty.
The problem seems to be that /etc/logrotate.d/rsyslog contains, in the mail.log section:
postrotate
invoke-rc.d rsyslog rotate > /dev/null
endscript
This invokes the rc.d rsyslog script that relies on syslog's PID being in /run/rsyslogd.pid. Debian 11 (and possibly all distros that use systemd?) no longer uses this PID file.
A solution is to replace those three lines with:
postrotate
/usr/lib/rsyslog/rsyslog-rotate
endscript
rsyslog-rotate is a script (provided with Debian 11 and possibly all sytemd distros) that contains:
#!/bin/sh
if [ -d /run/systemd/system ]; then
systemctl kill -s HUP rsyslog.service
else
invoke-rc.d rsyslog rotate > /dev/null
fi
so works whether or not systemd is being used.
----
Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.