We will create a systemd.timer to rotate Postfix’s log files created by the postlogd. Timers can be triggered by systemd dependencies or based on different events. Jobs triggered by timers can be configured to run in specific environments and their configuration files end on “.timer”.
Each timer file requires a matching unit file.
Our timer will trigger a simple postfix-logroate.service every Sunday at 00:00h.
[Unit] Description=Rotate Postfix logfiles on a weekly basis [Timer] Unit=postfix-logrotate.service OnCalendar=Sun *-*-* 00:00:00 [Install] WantedBy=timers.target
[Unit] Description=Rotates logs maintained by Postfix postlogd Wants=postfix-logrotate.timer [Service] Type=oneshotExecStart=/usr/sbin/postfix logrotate [Install] WantedBy=multi-user.target
We can interact with timers in the same way that we interact with services using the systemctl command.
systemctl status postfix-logrotate.timer
● postfix-logrotate.timer - Rotate Postfix logfiles on a weekly basis
Loaded: loaded (/usr/lib/systemd/system/postfix-logrotate.timer; enabled ; preset: enabled)
Active: active (waiting) since Fri 2026-05-29 13:36:43 CEST; 3 days ago
Invocation: 0ccf705c63d847a8a36503d383666db7
Trigger: Sun 2026-06-07 00:00:00 CEST; 5 days left
Triggers: ● postfix-logrotate.service
May 29 13:36:43 edi systemd[1]: Started postfix-logrotate.timer - Rotate Postfix logfiles on a weekly basis.
systemctl list-timers postfix-logrotate NEXT LEFT LAST PASSED UNIT ACTIVATES Sun 2026-06-07 00:00:00 CEST 5 days Sun 2026-05-31 00:00:05 CEST 1 day 21h ago postfix-logrotate.timer postfix-logrotate.service