Run Daily Tasks with Linux systemd Timers

Quick Linux Tip #70:

Question: How do I run a task daily but with more control than cron?

Try: sudo systemctl edit --force --full backup.timer

Info: systemd timers provide a flexible alternative to cron with native logging through journalctl, dependency control, Persistent=true for missed runs, and RandomizedDelaySec to spread system load.

Examples:

  • $ systemctl list-timers --all  # List all active system timers
  • $ journalctl -u backup.service  # Check execution history and logs
  • $ systemd-analyze calendar 'weekly'  # Parse and test calendar expressions

Note: Requires a paired .service unit file. Use OnBootSec for boot-relative timers and OnCalendar for wall-clock scheduling. Persistent=true can trigger a missed timer after the system comes back online, while RandomizedDelaySec adds a random delay to spread workload.




LinuxTeck.com
linuxteck@ubuntu:~$ sudo systemctl edit --force --full backup.timer

linuxteck@ubuntu:~$ cat /etc/systemd/system/backup.timer
[Unit]
Description=Run backup daily at 2 AM
Requires=backup.service

[Timer]
OnCalendar=*-*-* 02:00:00
RandomizedDelaySec=1800
Persistent=true

[Install]
WantedBy=timers.target

linuxteck@ubuntu:~$ sudo systemctl enable --now backup.timer
Created symlink /etc/systemd/system/timers.target.wants/backup.timer → /etc/systemd/system/backup.timer.

linuxteck@ubuntu:~$ systemctl list-timers backup.timer
NEXT                         LEFT   LAST PASSED UNIT         ACTIVATES
Sat 2026-09-12 02:00:00 UTC 15h left n/a  n/a   backup.timer  backup.service
linuxteck@ubuntu:~$

PREVIOUS ARTICLE Quick Linux Tip #69: How to Check Active Web Server Connections in Linux with ss NEXT ARTICLE Quick Linux Tip #71: How to Trace Dynamic Library Calls in Linux with ltrace
About John Britto

John Britto Founder & Chief-Editor @LinuxTeck. A Computer Geek and Linux Intellectual having more than 20+ years of experience in Linux and Open Source technologies.

View all posts by John Britto →

Leave a Reply

Your email address will not be published.