/tutorials/cron-syntax-explained
Cron Syntax Explained
How to read the five fields in a standard cron expression, and the ranges, steps and lists that make them more flexible than they first look.
5 min read
Run Cron Expression ExplainerRelated tools
The five fields, in order
A standard cron expression has five fields, always in the same order: minute, hour, day of month, month, and day of week. Each field can be a specific value or an asterisk meaning every possible value for that field, so 0 9 * * * means at minute 0 of hour 9, every day of every month, every day of the week, which in plain terms is every day at 9am.
Ranges, steps and lists make fields more flexible
- A range like 1-5 in the day of week field means Monday through Friday.
- A step like */15 in the minute field means every 15 minutes.
- A list like 1,15 in the day of month field means the 1st and the 15th specifically.
- These can combine, so 0 9 * * 1-5 means 9am on weekdays only.
Day of month and day of week are evaluated independently
A common point of confusion is that day of month and day of week are two separate fields that both default to 'every' with an asterisk. If both are restricted at once, most cron implementations run the job whenever either condition is satisfied, not only when both are true simultaneously, which is the opposite of how most people intuitively read it the first time.
Beyond standard five field syntax
Some schedulers extend cron with shorthand like @daily or @hourly, or add a sixth field for seconds. These are convenient but are extensions specific to whatever system supports them, not part of the original five field standard, so they will not parse the same way (or at all) in a tool built strictly around the standard syntax.
Trying it yourself
Cron Expression Explainer takes a standard five field expression and describes in plain English exactly when it will run. Paste in a schedule from a real config file before deploying it, specifically to catch a day of week versus day of month mixup before it runs at the wrong time in production.
Related tutorials
