systemd timers are a modern alternative to cron to schedule tasks. However, they’re a bit more work to setup than a cron job.

Timers explicitly execute systemd services, so for running a script once an hour, as an example, you need to have a oneshot service that runs the script. User specific services and timers live in ~/.config/systemd/user/. Since there isn’t a cron daemon backing this, these timers only execute when the user is logged in.

A very basic example (myservice.service):

[Unit]
Description=Run my script

[Service]
Type=oneshot
ExecStart=/path/to/your/script.sh

Then, a timer must also be created to execute this one shot services (myservice.timer):

[Unit]
Description=Timer for my script

[Timer]
# Run 5 minutes after booting
OnBootSec=5min
# Run 1 hour after the last time it ran
OnUnitActiveSec=1h
# Alternatively, use a calendar event (e.g., daily at 10 AM)
# OnCalendar=*-*-* 10:00:00

[Install]
WantedBy=timers.target

Start and enable the timer:

systemctl --user daemon-reload # to pick up changes
systemctl --user enable --now myservice.timer
# Run our service to start our hour timer (above example specific)
systemctl --user start myservice
# verify
systemctl --user list-timers