How cron syntax works: the five fields, steps and the day-of-week trap
What each of cron's five fields means, how *, commas, ranges and steps combine, and why 'first Monday of the month' lines run far more often than planned.
Open the Cron explainer Free, in your browser, nothing uploaded.
Cron is the scheduler built into Linux and most Unix-like servers. A single line such as 30 8 * 1,4,7,10 1-5 tells it when to run a job, and the same short syntax turns up in cloud schedulers, CI pipelines and backup tools. This article explains how that syntax is read, so you can spot a schedule that will misfire before it does. It is for developers, system administrators and anyone who has inherited a crontab. To turn run times into Unix timestamps for logs, use timestamp converter; to check the permissions on the script cron will call, try chmod calculator; and to search the job’s log output, see regex tester.
What it is
A standard cron line has five fields, separated by spaces, followed by the command to run:
| Field | Allowed values |
|---|---|
| Minute | 0 to 59 |
| Hour | 0 to 23 |
| Day of month | 1 to 31 |
| Month | 1 to 12, or jan to dec |
| Day of week | 0 to 6 with Sunday as 0 (7 is also Sunday), or sun to sat |
Each field is a set of allowed values, built from a few symbols:
*means every value.,makes a list:1,15is the 1st and the 15th.-makes a range:9-17is 9 to 17 inclusive./makes a step:*/15is every 15th value from the start (0, 15, 30, 45), and10-30/5is 10, 15, 20, 25 and 30.
Cron checks the clock once a minute. A job runs when the minute, hour and month all match and the day matches.
That last part has a famous twist. When both day of month and day of week are restricted (neither is *), cron runs when either matches, not both. So there is no direct way to say “the first Monday of the month” in standard cron.
Shortcuts replace whole lines: @hourly is 0 * * * *, @daily is 0 0 * * *, @weekly is 0 0 * * 0, @monthly is 0 0 1 * *, @yearly is 0 0 1 1 *, and @reboot runs once at start-up.
How to use it
- Type or paste a line into Cron line, or choose one from Ready-made lines.
- Or build it field by field in the Minute, Hour, Day of month, Month and Day of week boxes.
- Read the sentence under the line. If it is red, it names the field that is wrong.
- Check Next 10 run times, listed from now in your device’s time zone.
- Press Copy times or Copy cron line.
A worked example
A team wants a report job at 3:00 a.m. on the first Monday of each month, and writes:
0 3 1-7 * 1
The first Monday always falls between the 1st and the 7th, so it looks right. The explainer reads it back as “At 3:00 AM, on the 1st, 2nd, 3rd, 4th, 5th, 6th and 7th of the month or Monday (cron runs when either day matches)”. Starting from noon on Saturday 5 December 2026, the next 10 runs are:
Sun 6 Dec, Mon 7 Dec, Mon 14 Dec, Mon 21 Dec, Mon 28 Dec, Fri 1 Jan 2027, Sat 2 Jan, Sun 3 Jan, Mon 4 Jan and Tue 5 Jan, all at 03:00.
In a typical month that is all 7 of the first days plus every other Monday, about 10 or 11 runs instead of 1.
The fix is to let cron run on days 1 to 7 only, 0 3 1-7 * *, and have the script itself exit unless today is a Monday (many people add a test such as [ "$(date +\%u)" = 1 ] before the command). The explainer shows 0 3 1-7 * * running on 6 and 7 December, then 1 to 7 January, then 1 February: seven nights a month, of which the script acts on one.
The line 30 8 * 1,4,7,10 1-5 reads as “At 8:30 AM, on weekdays (Monday to Friday), in January, April, July and October”. Day of month is *, so the trap does not apply. Its first run after 5 December 2026 is Friday 1 January 2027 at 08:30.
Checked with the tools
The sentences and dates above came from the explainer’s own code (src/lib/dev/cron.ts) run in Node: parseCron() and explain() for the readings, and nextRuns() from 12:00 on 5 December 2026, in UTC, for the run lists. */7 in the day field gave days 1, 8, 15, 22 and 29.
Where it is used
- Server maintenance. Backups, log rotation and certificate renewals on Linux machines.
- Cloud and CI schedules. Many hosted schedulers and build pipelines take a five-field cron line, often in UTC.
- Data jobs. Nightly imports, report emails and cache refreshes.
Common mistakes
- Restricting both day fields. As shown above, it means “either”, not “both”. Restrict one and test the other in the script.
- Forgetting the time zone. A server in UTC runs
0 9 * * *at 9:00 UTC, which may be early morning or afternoon for you. Daylight saving can also skip or repeat a run. - Using
*in the minute field by accident.* 3 * * *runs every minute from 3:00 to 3:59, 60 times. - Pasting a six-field line. Some systems add seconds or a year and use
?. Standard cron will reject or misread it.
Questions people ask
Does */7 in the day field mean every 7 days? No. It means days 1, 8, 15, 22 and 29 of each month, so the gap at the month’s end is shorter.
Can cron run a job every 90 minutes? Not in one line. Use two lines, or a loop in the script.
Sources
- Standard five-field cron as described in the crontab(5) manual page (Vixie cron): minute, hour, day of month, month, day of week; fibub's own working.
If you are an author or publisher and want a credit or a passage changed or removed, tell us and we will act quickly.