Custom systemd units

Auto-update timers. Each runs every 30 minutes. Unit files are in /etc/systemd/system/.

UnitDoes
update-notes.service + .timerPulls the notes repo and rebuilds/deploys to /var/www/notes
song-rating-pull.service + .timergit pull of <GITHUB_USER>/<SONG_REPO> into /var/www/song_rating

Typical timer pattern

Note

This is a generic example, not copied from the server. Check the real files with systemctl cat update-notes.timer.

# <name>.timer
[Unit]
Description=Run <name> every 30 minutes
 
[Timer]
OnBootSec=2min
OnUnitActiveSec=30min
Persistent=true
 
[Install]
WantedBy=timers.target

Commands

systemctl list-timers update-notes.timer song-rating-pull.timer
sudo systemctl start update-notes.service          # run now
journalctl -u update-notes.service -n 50
sudo systemctl daemon-reload                       # after editing unit files
sudo systemctl enable --now <name>.timer

Back: 00 - Overview