I wanted to schedule a recurring action on my Linux machine recently and was reminded that timers have replaced crontab as the tool of choice. They’re really powerful, but I always have to look up how to use them.
I edit these so rarely, I have to look up the syntax for specifying when I’d like an action to happen. The last time I did this, I came across a handy one liner to help crafting these:
systemd-analyze calendar $CALENDAR_SPEC
This command is useful to “Validate repetitive calendar time events”
$ systemd-analyze calendar "*-*-* 01/4:49:00" Normalized form: *-*-* 01/4:49:00 Next elapse: Thu 2022-08-04 17:49:00 EDT (in UTC): Thu 2022-08-04 21:49:00 UTC From now: 2h 46min left
If that makes sense for the goal of the timer, you can safely put it in an
OnCalendar statement! Make sure you remember to run
systemctl --user daemon-reload to pick up the changes.
To check your configured timers, run:
systemctl --user list-timers