flashman
← All posts

systemd OnCalendar versus cron debugging

Debug systemd OnCalendar misses by translating weekdays, ranges, time zones, and persistent timers into the five-field cron schedule you meant to run.

2026-09-30 · 6 min read · Rahul Chitturi

  • cron
  • systemd
  • scheduling

systemd calendar events are not five-field cron. OnCalendar uses a date and a clock time, with optional weekdays written as names: Mon *-*-* 09:00:00. The cron expression 0 9 * * 1 is easy to paste into the wrong field and then read as a date.

When both a day of the month and a weekday are set, systemd requires both to match. Many cron implementations run the job when either field matches. A schedule moved between the two can skip the Monday you added or fire on an extra date.

Read the unit, the zone, and the accuracy

Save the timer unit, the service it starts, the time zone of that machine, and whether Persistent=, AccuracySec=, or RandomizedDelaySec= is set. AccuracySec= often defaults to one minute, so a job timestamped 09:00:07 can still be the 09:00 calendar event.

  • Count whether the string is cron or a calendar event.
  • Prefer weekday names in OnCalendar expressions.
  • Record the container time zone separately from the host.
  • Check Persistent= if the machine was off at the trigger.

Translate the next runs, then encode

Write the intended instants in words before encoding them. Daily at 02:00 is *-*-* 02:00:00. Every 15 minutes is a form such as *:0/15, which is not the cron token */15 dropped into a unit file.

A calendar event uses local time unless the expression sets a zone. A container whose TZ is UTC will not follow a laptop set to a named region, even when the unit text matches.

Preview both dialects before enabling the timer

Use Flashman's cron helper for the five-field meaning, the timestamp converter for the zone, diff for the unit change, and the Markdown editor to store the sentence next to OnCalendar.

Compare the next runs across a daylight-saving change, a boot after a missed slot, and a weekday-plus-date expression. Enable the timer only after those instants match the sentence.

Try these tools