Preserve cron day rules when creating a systemd timer
Admin ·
A cron expression with two restricted day fields can match two sets of dates. Converting the expression requires preserving that relationship in the timer section.
Cron to systemd Timer Converter
Keep Mondays and the first of the month
Enter 30 8 1 * MON. The timer includes OnCalendar=*-*-01 08:30:00 UTC and OnCalendar=Mon *-*-* 08:30:00 UTC. The first directive covers month starts and the second covers Mondays.
Trace the month boundary
Set the preview start to 28 April 2024 at 00:00 UTC. Monday 29 April and Wednesday 1 May both appear at 08:30. A single directive requiring Monday and day 01 would skip both dates.
Check whether the source schedule really uses UTC
If an existing job runs at 08:30 local time, copying an 08:30 UTC timer changes the wall-clock hour wherever the offset is nonzero. Write down one known execution with its timezone and compare it with the generated directives.
Treat a converted calendar expression as the timing portion of the setup. Check the service associated with the timer separately and inspect its next scheduled occurrence before replacing an existing job.
Common questions
Why do the seconds show 00?
A five-field cron schedule has minute precision. The calendar expression targets second zero of each selected minute. Actual activation timing also depends on systemd settings such as AccuracySec.
Is schedule.timer.txt a complete installable service?
The download contains a [Timer] section for review and integration. The executable action belongs in the associated service unit.
Sources
Put it into practice.
- Cron to systemd Timer Converter
- Cron Expression Translator and Validator
- Crontab Expression Builder
- Unix timestamp converter