> In case of an error during the log rotation, e.g. a gzip failure
> with "warning: file timestamp out of range for gzip format"[*],
> when log rotation is done via the systemd timer, one does not get
> any mail, contrary to cron jobs.

This is indeed a disadvantage of systemd-timers compared to cron jobs.
(see https://wiki.archlinux.org/index.php/Systemd/Timers#Caveats)

In my opinion the advantages (more robust triggering on non 24/7 systems,
more security by service hardening options) outweigh.

It is possible to switch back by disabling the timer

    systemctl stop logrotate.timer
    systemctl disable logrotate.timer

and commenting out the following lines in /etc/cron.daily/logrotate

    if [ -d /run/systemd/system ]; then
        exit 0
    fi


> The error message is in the systemd logs, but this is not sufficient.
> Logs are fine for informational messages in order to debug or to try
> to find the cause of a problem, but for something that requires a
> manual intervention like here, the user must be informed, otherwise
> the problem may remain unnoticed for a long time.

You can monitor 'systemctl is-system-running', or use something like
the following timer:

#### timer
[Unit]
Description=Daily log warnings report
After=systemd-journald.service
[Timer]
OnCalendar=*-*-* 23:59:40
AccuracySec=10s
Persistent=true
[Install]
WantedBy=systemd-journald.service

#### service
[Unit]
Description=Daily log warnings report
[Service]
Type=oneshot
ExecStart=/bin/sh -c "/bin/journalctl --priority error --since today |
mail -s 'log warnings daily report' root"
KillMode=process

Reply via email to