Systemd timer syntax

From wikinotes

Timer files can be used to control when a systemd service of the same name runs.
It is similar to cron.

Documentation

official docs https://www.freedesktop.org/software/systemd/man/systemd.timer.html

Example

Vdirsyncer is a good example.

# /etc/systemd/system/vdirsyncer.timer

[Unit]
Description=Synchronize vdirs

[Timer]
OnBootSec=5m          # run 5m after boot
OnUnitActiveSec=15m   # also run every 15m
AccuracySec=5m

[Install]
WantedBy=timers.target
# /etc/systemd/system/vdirsyncer.service

[Unit]
Description=Synchronize calendars and contacts
Documentation=https://vdirsyncer.readthedocs.org/

[Service]
ExecStart=/usr/bin/vdirsyncer sync
Type=oneshot
systemctl enable vdirsyncer.timer