• 15 Posts
  • 196 Comments
Joined 2 years ago
cake
Cake day: April 21st, 2024

help-circle












  • My number one reason for using systemd timers is just that I find it more readable than cron. Usually I want to run things daily, weekly or monthlyand systemd timers make that very easy.

    Here is an example:

    backup.timer

    [Unit]
    Description=Run backup database daily
    
    [Timer]
    OnCalendar=daily
    RandomizedDelaySec=10
    
    [Install]
    WantedBy=timers.target
    

    backup.service

    [Unit]
    Description=Backup database
    
    [Service]
    Type=oneshot
    ExecStart=/bin/bash /path/to/backupscript.sh
    

    Another great feature is that the output of the script is logged to journald which is very convenient when you are troubleshooting why your backup failed last night.