Crontab ⇄ systemd Timer Converter

Paste a crontab line to get a matching .service and .timer unit with the correct OnCalendar= syntax, the commands to install it and its next run times. Or go the other way and turn an OnCalendar= expression back into a crontab schedule.

    Examples:

    job.service

    
              
            

    job.timer

    
              
            

    Install & check

    
              
            

    Next runs

      Why move cron jobs to systemd timers?

      On any Linux distribution that boots with systemd you can replace a crontab entry with two small unit files: a .service that says what to run and a .timer that says when. It's more typing than one crontab line, but you get a lot in return:

      Cron is still simpler for a quick personal job, works on systems without systemd (Alpine with OpenRC, BSDs, many containers) and is understood by everyone. Use whichever fits.

      OnCalendar= syntax

      A calendar event has the form DayOfWeek Year-Month-Day Hour:Minute:Second. The weekday is optional, an omitted date means every day (*-*-*), and an omitted time means midnight. Seconds are optional and default to 00.

      Mon..Fri  *-*-*  09:30:00
      |         | | |  |  |  `-- second
      |         | | |  |  `-- minute
      |         | | |  `-- hour
      |         | | `-- day of month (or ~N = Nth-last day)
      |         | `-- month
      |         `-- year
      `-- weekdays (optional): Mon Tue Wed Thu Fri Sat Sun

      Always check an expression before you deploy it. systemd-analyze calendar --iterations=5 'Mon..Fri 09:30' prints the normalized form and the next five times it matches.

      Cron to OnCalendar examples

      crontabOnCalendar=
      * * * * **-*-* *:*:00 (or minutely)
      */5 * * * **-*-* *:00/5:00
      0 * * * **-*-* *:00:00 (or hourly)
      30 2 * * **-*-* 02:30:00
      0 9 * * 1-5Mon..Fri *-*-* 09:00:00
      0 10 * * 6,0Sat,Sun *-*-* 10:00:00
      0 0 1 * **-*-01 00:00:00 (or monthly)
      0 0 1 1,4,7,10 **-01,04,07,10-01 00:00:00 (or quarterly)
      0 0 * * 0 (@weekly)Sun *-*-* 00:00:00. systemd's weekly means Monday.
      @rebootNo calendar event. Use OnBootSec=1min in the timer instead.

      Differences to watch out for