Cron Syntax Explained: How to Read, Write, and Debug Any Cron Expression
Learn the five cron fields, step and range syntax, the day-of-month OR day-of-week trap, and time zone pitfalls, then test any expression.
A cron expression is five short fields that decide when a job runs. It looks like line noise until you know the pattern, and then it stays easy to read, apart from a few traps that catch almost everyone once. This guide covers the syntax, the traps, and how to check an expression before it runs in production. You can follow along in the cron expression tester, which explains any expression in plain English and lists its next run times.
The five fields
A standard cron expression has five fields separated by spaces, always in this order:
| Position | Field | Allowed values |
|---|---|---|
| 1 | Minute | 0-59 |
| 2 | Hour | 0-23 |
| 3 | Day of month | 1-31 |
| 4 | Month | 1-12 (or JAN-DEC) |
| 5 | Day of week | 0-7 (0 and 7 are Sunday, or SUN-SAT) |
So 30 2 * * 0 means minute 30, hour 2, any day of the month, any month, on Sunday: every Sunday at 02:30. An asterisk means "every value" for that field.
Lists, ranges, and steps
Three characters cover most of what you need:
- A comma makes a list:
0 9,17 * * *runs at 09:00 and 17:00. - A hyphen makes an inclusive range:
0 9 * * 1-5runs at 09:00 on weekdays. - A slash makes a step:
*/5 * * * *runs every five minutes, and0-30/10 * * * *runs at minutes 0, 10, 20, and 30.
Steps always count from the start of the field's range, not from when the job was last run. That matters when the step does not divide evenly. */7 * * * * runs at minutes 0, 7, 14, and so on up to 56, then starts over at minute 0 of the next hour, leaving a gap of only four minutes. If you need a true "every 90 minutes", a single standard expression cannot do it; run a job every 30 minutes and have it decide whether to act, or use a scheduler that supports intervals.
Many cron implementations also accept shortcuts such as @hourly, @daily, @weekly, @monthly, and @reboot. These come from Vixie cron and its descendants and are not part of the POSIX specification, so check that your scheduler supports them before relying on them.
The day-of-month and day-of-week trap
This is the one that bites. When you restrict both the day-of-month field and the day-of-week field, standard cron runs the job when either one matches, not when both match.
Say you want "09:00 on the first Monday of the month" and write 0 9 1-7 * 1. It reads as days 1 through 7 and Monday. But cron treats it as days 1 through 7 or any Monday. Run through the cron tester starting on December 1, 2026, the next runs are every morning from Tuesday December 1 through Sunday December 6, because each of those days is in the 1-7 range.
The usual workaround is to schedule the broader field and check the rest inside the job. For the first Monday, run 0 9 * * 1 and have the script exit unless the day of the month is 7 or less. The same idea works for "last day of the month": run on days 28 through 31 and exit unless tomorrow is the first. In a crontab, remember that a bare % in the command line is treated as a newline, so escape it as \%.
Expressions you will actually use
| Expression | Meaning |
|---|---|
*/5 * * * * |
Every 5 minutes |
0 * * * * |
Every hour, on the hour |
0 9 * * 1-5 |
09:00 on weekdays |
30 2 * * 0 |
02:30 every Sunday |
0 0 1 * * |
Midnight on the first of every month |
0 0 1 1 * |
Midnight on January 1 |
Time zones and daylight saving time
A cron expression has no time zone of its own. It runs in whatever zone the scheduler uses, and that varies:
- A traditional cron daemon uses the server's local time.
- GitHub Actions schedules run in UTC, and the shortest supported interval is every five minutes. Scheduled runs can also be delayed when GitHub is under heavy load.
- A Kubernetes CronJob uses the controller's local time zone unless you set the
timeZonefield on the CronJob. Set that field rather than putting a zone inside the schedule string.
Daylight saving time makes local-time schedules awkward. A job set for 02:30 local time may not have a 02:30 on the night clocks spring forward, and the hour from 01:00 to 02:00 happens twice when they fall back. How a scheduler handles that is implementation-specific, and some daemons have special handling for small clock changes while many managed schedulers do not. The simplest way to avoid surprises is to schedule important jobs in UTC, or at least to avoid the 01:00 to 03:00 local window. For background, see how daylight saving time works and the DST scheduling bugs that calendar apps hit. If you need to compare a local run time against UTC, the timezone converter handles the offsets, and UTC vs GMT explains why UTC is the safer reference.
Dialects that look the same but are not
Several systems borrow cron's look without matching its rules:
- Quartz adds a seconds field at the front and supports characters such as
L(last) and#(nth weekday), which standard cron does not. - AWS EventBridge uses six fields, adds a year, and does not let you set day-of-month and day-of-week together; you use a question mark in one of them.
- Six-field expressions in some libraries put seconds first. The tester accepts five or six fields, so paste yours in and read the plain-English summary to confirm how it was interpreted.
When you move an expression between systems, re-read its meaning in the target system's documentation, not just its syntax.
How to check an expression before you ship it
Paste the expression into the cron expression tester, pick the time zone your scheduler uses, and read two things: the plain-English description, and the next five or so run times. If the description does not match your intent, or the run times surprise you, fix the expression before it runs for real. The same check is available programmatically through the free time API and MCP server, which exposes a cron_next_runs tool.
Frequently asked questions
What does * * * * * mean? Every minute of every hour of every day.
How do I run a job every 10 minutes? Use */10 * * * *.
Why did my job run on days I did not expect? You probably restricted both day-of-month and day-of-week, so cron ran the job when either matched. See the trap above.
Sources
- crontab(5) manual page, Linux man-pages project
- crontab utility specification, POSIX, The Open Group
- Events that trigger workflows: schedule, GitHub Docs
- CronJob, Kubernetes documentation
- Cron expressions reference, Amazon EventBridge User Guide
We build practical, free time and date tools at epochcalc.com — every calculation runs in your browser using IANA tzdb via Luxon, so DST and zone math are correct by construction.