Workflow Tools Control Yard

Home / Linux

Cron expression explainer

Paste a line from a crontab, such as 30 2 * * 1-5 and a command, or only its five time fields. The page says in words when it runs, lists its next runs, and points out what often surprises people. Below it, build a schedule. It follows the crontab format as cronie documents it, and reads the text in your browser.

Build a schedule

Time fields

0 2 * * 1-5
How often
When
Days

The five fields

A line holds five time fields, then the command. A line of /etc/crontab or /etc/cron.d also names the user who runs it, between the fields and the command. cron checks every minute, and runs a command when the minute, the hour and the month match and the day matches. If both day fields are restricted, either one is enough: 30 4 1,15 * 5 runs at 4:30 on the 1st and the 15th and on every Friday.

PlaceFieldValuesAlso
1Minute0 to 59
2Hour0 to 23
3Day of month1 to 31
4Month1 to 12or jan to dec
5Day of week0 to 70 and 7 are Sunday; or sun to sat

What a field can hold

ExampleWhat it means
*Every value of the field.
5That value.
8-11A range, both ends included.
1,15A list of values or ranges.
*/15Every 15th value from the start of the field: 0, 15, 30, 45 in minutes.
0-23/2Every 2nd value within the range.
mon-friNames, by their first three letters, for months and days of the week.
6~15A random value within the range, picked when cron reads the crontab (cronie).

A step counts within its own field only: */23 in the hour field runs at 0:00 and 23:00, not every 23 hours.

Nicknames

NicknameWhenSame as
@rebootOnce, after the system starts.
@yearlyOnce a year.0 0 1 1 *
@annuallyOnce a year.0 0 1 1 *
@monthlyOnce a month.0 0 1 * *
@weeklyOnce a week.0 0 * * 0
@dailyOnce a day.0 0 * * *
@hourlyOnce an hour.0 * * * *

What surprises people

Sources

More Linux tools