GrepBoard/Manuals
605 manuals ·

Check a systemd timer OnCalendar value before installing it

·Tested on Ubuntu 24.04.5 · systemd 255.4-1ubuntu8.18 (time zone Asia/Seoul)·Test scope ↓·8 steps

Run systemd-analyze calendar to see the normalized form and next run time of an OnCalendar value before it goes into a unit, and tell parse errors from never.

You can find out when OnCalendar=Mon *-*-* 03:00 fires without creating a unit or starting a timer. Dates and From now values below come from the day of testing (2026-10-19), so yours will differ.

[1] Quote the expression and pass it to systemd-analyze calendar.

console
$ systemd-analyze calendar "Mon *-*-* 03:00"  Original form: Mon *-*-* 03:00Normalized form: Mon *-*-* 03:00:00    Next elapse: Mon 2026-10-26 03:00:00 KST       (in UTC): Sun 2026-10-25 18:00:00 UTC       From now: 6 days left

Normalized form is how systemd read the expression; the seconds were filled in as :00. Next elapse is in the system time zone, and (in UTC) shows the same moment in UTC.

[2] Add --iterations=N to see more than one run.

console
$ systemd-analyze calendar --iterations=3 "Mon *-*-1..7 03:00"  Original form: Mon *-*-1..7 03:00Normalized form: Mon *-*-01..07 03:00:00    Next elapse: Mon 2026-11-02 03:00:00 KST   Iteration #2: Mon 2026-12-07 03:00:00 KST   Iteration #3: Mon 2027-01-04 03:00:00 KST

This is "first Monday of the month", written as a weekday plus days 1..7. All three results are Mondays within the first seven days. --base-time=DATE moves the starting point, which helps when you want to preview a year boundary.

[3] See how the shortcut names expand.

console
$ systemd-analyze calendar daily weekly monthly | grep NormalizedNormalized form: *-*-* 00:00:00Normalized form: Mon *-*-* 00:00:00Normalized form: *-*-01 00:00:00

weekly means Monday 00:00. The table in systemd.time(7) agrees.

[4] For interval expressions, read the normalized form.

console
$ systemd-analyze calendar "*:0/15" | grep NormalizedNormalized form: *-*-* *:00/15:00

Per systemd.time(7), a value followed by / matches the start value and every multiple of the repetition after it. Here that is minutes 0, 15, 30 and 45 of every hour.

[5] Write the last day of a month with ~. The same man page says *-02~03 is "the third last day in February" and Mon *-05~07/1 is "the last Monday in May".

console
$ systemd-analyze calendar "*-*~01 02:00" | grep Next    Next elapse: Sat 2026-10-31 02:00:00 KST$ systemd-analyze calendar "Mon *-05~07/1 00:00" | grep Next    Next elapse: Mon 2027-05-31 00:00:00 KST

[6] A time zone at the end of the expression is used instead of the system zone.

console
$ systemd-analyze calendar "Sat,Sun 03:00 UTC"  Original form: Sat,Sun 03:00 UTCNormalized form: Sat,Sun *-*-* 03:00:00 UTC    Next elapse: Sat 2026-10-24 12:00:00 KST       (in UTC): Sat 2026-10-24 03:00:00 UTC

If you meant 03:00 Korean time and wrote UTC, the job runs at 12:00. Check that Next elapse and (in UTC) are the times you intended.

[7] Learn the error text. An hour of 25 or a 3am style time fails to parse, and the exit code is 1.

console
$ systemd-analyze calendar "Mon *-*-* 25:00"Failed to parse calendar specification 'Mon *-*-* 25:00': Invalid argument$ systemd-analyze calendar "*-*-* 3am"Failed to parse calendar specification '*-*-* 3am': Invalid argument

A valid expression for a date that does not exist is not an error. The exit code is 0 and the result is never.

console
$ systemd-analyze calendar "*-02-30 00:00"  Original form: *-02-30 00:00Normalized form: *-02-30 00:00:00    Next elapse: never

A timer with this value never runs and reports no error, so recheck the date whenever you see never.

[8] To catch typos inside the unit file too, run systemd-analyze verify on the file path without installing it.

console
$ systemd-analyze verify ./backup.timer./backup.timer:5: Failed to parse calendar specification, ignoring: Mon *-*-* 25:00backup.timer: Timer unit lacks value setting. Refusing.Unit backup.timer has a bad unit file setting.$ echo $?1

A misspelled key such as OnCalender= prints Unknown key name 'OnCalender' in section 'Timer', ignoring. followed by the same Refusing. line. A valid file prints nothing about that unit and exits 0. Warnings about other units already on the system may appear too, so read only the lines carrying your file name.

If the server runs cron instead of timers, see cron job not running.

Check it with the cron · systemd time expressions tool ↗ — calculated in your browser.

#systemd#timer#systemd-analyze