Cron → systemd Timer Converter
Paste one cron line or an entire crontab. You get the equivalent OnCalendar= expression, the next run times, and ready-to-install .service and .timer units.
Cron vs OnCalendar syntax
| cron | systemd OnCalendar | meaning |
|---|---|---|
| */15 * * * * | *-*-* *:00/15:00 | every 15 minutes |
| 0 * * * * | *-*-* *:00:00 (hourly) | top of every hour |
| 30 2 * * * | *-*-* 02:30:00 | daily at 02:30 |
| 0 9 * * 1-5 | Mon..Fri *-*-* 09:00:00 | weekdays at 09:00 |
| 0 0 1 * * | *-*-01 00:00:00 (monthly) | first of the month |
| 0 0 1 1 * | *-01-01 00:00:00 (yearly) | 1 January |
| @reboot | OnBootSec=1min | after boot |
The day-of-month / day-of-week trap
In cron, if both the day-of-month and day-of-week fields are restricted, the job runs when either matches. 0 9 1,15 * mon runs on the 1st, the 15th and every Monday. In systemd, every component of an OnCalendar expression must match, so a naive one-line conversion would only fire on Mondays that fall on the 1st or 15th. This converter detects that case and emits two OnCalendar= lines, which systemd ORs together.
Other differences worth knowing
- Environment: cron jobs run with a minimal environment and
/bin/sh. The generated service keeps/bin/sh -cfor parity. AddEnvironment=lines if your job relies on variables set in the crontab. - Escaping: systemd treats
%as a specifier and$as variable expansion inExecStart=. The converter doubles both. - Output: cron mails output to MAILTO. systemd sends it to the journal (
journalctl -u name.service). - Missed runs: cron skips them.
Persistent=truemakes systemd catch up after downtime. - Overlap: a systemd service won't start a second instance while the previous run is still active. Cron will happily run two at once.
FAQ
How do I verify an OnCalendar expression?
Run systemd-analyze calendar --iterations=5 'expression' on the target machine. It prints the normalized form and the next trigger times.
Does systemd support cron step values like */5?
Yes. systemd uses start/step notation, so */5 in the minute field becomes 00/5, and a bounded range like 10-40/10 becomes the explicit list 10,20,30,40.
How do I set a timezone for a systemd timer?
Append an IANA timezone to the OnCalendar expression, e.g. OnCalendar=*-*-* 02:30:00 Europe/London. If your crontab sets CRON_TZ or TZ, the converter adds it automatically.
Why does the generated timer set AccuracySec=1s?
By default systemd may delay a timer by up to one minute to batch wakeups. Cron fires at the start of the minute, so AccuracySec=1s keeps the behaviour the same. Remove it if exact timing doesn't matter.