brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: Persistent=true gives a systemd timer the catch-up that plain cron lacks

Cron
~/tips/tip-cron-persistent-true-timer

Persistent=true

Makes a systemd timer run a missed job right after boot.

I like timers for jobs on machines that are not always on, because the catch-up is one line.

[Timer]
OnCalendar=daily
Persistent=true

With Persistent=true systemd records the last trigger time on disk, and when the machine was off at the scheduled moment it starts the service soon after the next boot. A cron line skips that run and anacron is the add-on that fixes it. The setting only has an effect on timers that use OnCalendar=. systemctl list-timers shows when each timer last ran and runs next.

Further reading: systemd.timer manual page

Going deeper: Guide: find out why a Linux service failed, with journalctl

More Cron tips echo 'systemctl restart myapp' | at 03:00 tomorrow 55 23 28-31 * * [ "$(date -d tomorrow +\%d)" = 01 ] && /usr/local/bin/month-end.sh EDITOR=nano crontab -e 30 6 * * mon /usr/local/bin/weekly-report.sh @daily /usr/local/bin/backup.sh All Cron tips (32) All topics

Link