Where to start First steps track · 15 stages
Linux Labs

cron and OnCalendar explained

A cron or OnCalendar schedule in plain words, with the next runs.

*/5 * * * * or @daily
Syntax crontab or a systemd timer
Time zone Where the runs are counted
Mon..Fri 09:00 or daily
Syntax crontab or a systemd timer
Time zone Where the runs are counted
Type an expression or pick a pattern below.
In words

—

Next runs
How many

No runs ahead.

The same in crontab and systemd

The result will appear here

As systemd-analyze calendar shows it

    

The result will appear here

Calculated in your browser — nothing is sent to the server

Practice on a machine

Lab “Cron job isn't running”

easy ~15 min stage 11 of the “Packages, services, and logs” track

Open the lab

In a Linux terminal

bash
crontab -l # the current user's jobs crontab -e # edit them systemd-analyze calendar 'Mon..Fri 09:00' # check an OnCalendar expression systemctl list-timers # systemd timers and their next run

Keep in mindIf both the day of month and the day of week are set, cron runs the job when either matches, not both.

FAQ

How do I run a cron job every 5 minutes?

*/5 * * * *. Every 5 minutes during working hours on weekdays: */5 9-18 * * 1-5.

Why does my cron job not run?

cron has a short PATH and none of your variables: use full paths to programs and escape % as \%. To see what ran: grep CRON /var/log/syslog.

What time zone does cron use?

The system's, shown by timedatectl. On a server in UTC, 0 9 * * * runs at 9:00 UTC, whatever your local time is.

Loading…