Cron to systemd timer converter

Turn a cron expression into a systemd OnCalendar line, with timer and service units ready to copy.

Enter a cron expression and the command to run ()

How cron maps to OnCalendar

A systemd timer’s OnCalendar= line has the form DayOfWeek Year-Month-Day Hour:Minute:Second. Cron’s fields map onto it directly:

CronOnCalendar
*/15 * * * **-*-* *:00/15:00
0 * * * **-*-* *:00:00
30 2 * * 1-5Mon..Fri *-*-* 02:30:00
0 0 1 * **-*-01 00:00:00

Differences worth knowing:

  • Missed runs. With Persistent=true, systemd runs a job that was missed while the machine was off as soon as it is back. Cron skips it.
  • Both day fields. In cron, setting both the day of month and the weekday means either one. In OnCalendar it means both, so the converter writes two OnCalendar= lines.
  • Time zone. Timers use the machine’s time zone unless you add one at the end, for example OnCalendar=Mon..Fri *-*-* 09:00:00 Europe/Berlin.
  • Logs. Output goes to the journal: journalctl -u backup.service.

Check any OnCalendar value with systemd-analyze calendar "Mon..Fri *-*-* 02:30:00", which prints the next time it fires.

Run online cronjobs without server setup

Plan, schedule and run periodic tasks and scripts, from your browser with the first online cronjob platform.

Try for free