Scheduling with systemd - Paiet/Tech-Journal-for-Everything GitHub Wiki
- systemd timers vs cron jobs
- Mostly a drop-in replacement
- systemd has a slightly more flexible time format
- Dependency tracking
- Logs to journald
- Creating systemd timers
- Create a service that depends on the timer
- Create the timer
- Monitor the journal to validate execution
/etc/systemd/system/backup.service
[Unit]
Description=Perform a backup
Wants=backup.timer
[Service]
Type=oneshot
WorkingDirectory=/home/nicholas/
ExecStart=/home/nicholas/backup.sh
[Install]
WantedBy=multi-user.target
/etc/systemd/system/backup.timer
[Unit]
Description=Schedules backups
Requires=backup.service
[Timer]
Unit=backup.service
OnCalendar=*-*-* *:*:00
[Install]
WantedBy=timers.target
- systemd timer format
man 7 systemd.time
-> Calendar Events
- Troubleshooting timers
- Look for errors
journalctl -u backup.service
- Check your syntax
- Check your service
systemd-run /home/nicholas/backup.sh