> Markdown version of https://opspane.dev/cron/systemd/ for AI agents and readers: the same text, without navigation or the interactive tool.
>
> The tool computes its result with JavaScript in the browser, so this file holds the reference text, worked examples and FAQ. Open the page to run it on your own input.
>
> Answer endpoint for agents: the same URL parameters on https://opspane.dev/cron/systemd/answer.md return the computed result as Markdown, without JavaScript, e.g. https://opspane.dev/cron/systemd/answer.md?expr=Mon..Fri%20*-*-*%2009%3A00%3A00&tz=Europe%2FBerlin

# systemd OnCalendar

Test systemd OnCalendar expressions, convert between cron and systemd timers, and generate ready-to-use .timer and .service files.

## Quick answer

- `OnCalendar=` reads `weekdays year-month-day hour:minute:second timezone`; every part is optional and all must match at the same time.
- Ranges use `..`, repeats `a/n`, and `~` counts from the month's end: `*:0/15` is every 15 minutes, `*-*~01` the last day of the month.
- From cron: `0 9 * * 1-5` is `Mon..Fri 09:00`. A cron schedule with both a day of month and a day of week becomes two `OnCalendar=` lines.
- Timers may fire up to a minute late (`AccuracySec=1min` by default), and `Persistent=true` catches up on runs missed while the machine was off.

## How to use

1. Type an `OnCalendar=` value or pick an example. The tool shows systemd's normalized form and the next 10 elapse times.
2. Fill in the unit name and command to get matching `.timer` and `.service` files.
3. Coming from cron? Paste the crontab schedule into the converter and press “Use this”.

## OnCalendar syntax

A calendar event has four parts in this order — `weekdays`, `year-month-day`, `hour:minute:second` and a `timezone` — and every part is optional. A missing date means `*-*-*`, a missing time means `00:00:00` and missing seconds mean `:00`. All parts must match at the same time.

| Syntax | Meaning | Example |
| --- | --- | --- |
| `*` | Any value | `*-*-* 12:00` every day at noon |
| `a,b` | List | `Mon,Wed,Fri 07:30` |
| `a..b` | Range | `*-*-* 9..17:00` every hour 09–17 |
| `a/n` | Repeat every n from a | `*:0/15` every 15 minutes |
| `~` | Days from the month's end | `*-*~01` the last day |
| zone | Evaluate in an IANA zone | `daily Europe/Berlin` |

Shorthands: `minutely`, `hourly`, `daily`, `weekly` (Monday 00:00), `monthly`, `quarterly`, `semiannually`, `yearly` / `annually`. A repetition must start from a number: `*/2` is rejected — write `0/2`.

## Cron to OnCalendar examples

| Schedule | cron | OnCalendar |
| --- | --- | --- |
| Every 15 minutes | `*/15 * * * *` | `*:0/15` |
| Weekdays at 09:00 | `0 9 * * 1-5` | `Mon..Fri 09:00` |
| First of the month | `0 0 1 * *` | `monthly` |
| Last day of the month | not possible | `*-*~01` |
| 1st OR Monday | `0 0 1 * 1` | two lines: `*-*-01` and `Mon *-*-*` |

## Gotchas this tool checks for

### Every part must match at the same time

A calendar event is a conjunction: the weekday, date and time parts must all match at the same elapse. `Mon..Fri *-*-15 09:00` elapses on 15 April 2026 (a Wednesday) but not on 15 August 2026 (a Saturday).

`Mon..Fri *-*-15 09:00` the 15th, only on weekdays

systemd **ANDs** every part of the date: 15 April 2026 is a Wednesday, so the timer elapses; 15 August 2026 is a Saturday — the weekday part fails and nothing elapses that day.

### `~` counts from the month's end

The `~` window counts back from the month's end: `*-*~07/1` covers the last 7 days — 25 to 31 in March 2026. Add a weekday and only a matching day inside the window elapses: `Mon *-*~07/1` fires on 30 March 2026, the last Monday of the month.

`Mon *-*~07/1` last 7 days of the month · March 2026

The `~` window counts back from the month's end: `~07/1` covers the last 7 days (25–31 in March 2026), walked from the 31st backwards. `Mon` picks the only Monday inside — **30 March**, the last Monday of the month.

## Daylight saving time

A timer whose time does not exist when clocks spring forward does not elapse that day. A time that happens twice when clocks fall back elapses once, at the first occurrence — different from cron, which runs it twice. Pick your time zone above and the warnings name the dates.

## How the results are verified

The normalized form and every elapse time are checked against `systemd-analyze calendar` from systemd 262 on 63 expressions and 210 time-zone and start-time combinations, including invalid input and the 2026 daylight-saving changes.

## FAQ

### Is it Mon..Fri or Mon-Fri in OnCalendar?

Both work for weekdays: systemd 262 accepts Mon-Fri and normalizes it to Mon..Fri. In the date and time parts, though, - and : are separators, so ranges there must use .. (for example *-*-1..7 or 9..17:00).

### How do I convert a cron expression to a systemd timer?

Paste it into the cron converter on this page. 0 9 * * 1-5 becomes Mon..Fri *-*-* 09:00:00. A cron schedule with both a day of month and a day of week becomes two OnCalendar= lines, because systemd requires weekday AND date to match.

### How do I test an OnCalendar expression?

On a Linux machine run systemd-analyze calendar "Mon..Fri 09:00" --iterations=5. This page does the same in the browser: it shows the normalized form and the next 10 elapse times, and its results are checked against systemd-analyze.

### Why does my timer fire a few seconds or a minute late?

Timers have AccuracySec=1min by default, so systemd may delay the run within that window to save wakeups. Set AccuracySec=1s in the [Timer] section if you need the exact second.

### What does Persistent=true do?

If the machine was off when the timer should have fired, Persistent=true runs the service once as soon as the timer is active again. Without it, missed runs are skipped.

### How do I run a timer on the last day of the month?

Use ~ to count days back from the end of the month: *-*~01 is the last day, *-*~03 the third-to-last. Mon *-*~07/1 is the last Monday of every month.

## Related tools

- [Cron Expression Explainer](https://opspane.dev/cron/explainer/): Understand any cron expression in plain English, with timezone-aware next run times and warnings for schedules that never fire.
- [Cron Expression Converter](https://opspane.dev/cron/translate/): Convert one schedule to crontab, Quartz, AWS EventBridge, GitHub Actions, Kubernetes and systemd — with next run times for each.
- [Kubernetes CronJob Generator](https://opspane.dev/cron/kubernetes/): Generate a complete CronJob manifest with schedule, timeZone, concurrencyPolicy and history limits, explained field by field.
