The five fields of a cron expression
A cron expression has five fields: minute, hour, day of month, month, and day of week. The expression '0 9 * * 1' runs at 9:00 AM every Monday. Each field specifies when the task should run in that time unit, and * means 'every' for that field.
Fields are read left to right. Minutes are 0–59, hours are 0–23, day of month is 1–31, month is 1–12 (or JAN–DEC), and day of week is 0–7 where both 0 and 7 represent Sunday (or SUN–SAT).
The format is: ┌───── minute (0–59) ┬───── hour (0–23) ┬───── day of month (1–31) ┬───── month (1–12) ┬───── day of week (0–7). Fields are read in that order.
- * — every value (every minute, every hour, etc.)
- , — list (1,3,5 means 1, 3, and 5)
- - — range (1-5 means 1 through 5)
- / — step (*/5 means every 5, starting from 0)
- ? — no specific value (used for day fields in some implementations)
Common cron expressions with explanations
Learning cron expressions is easiest through examples. Here are the most common schedules and how to write them.
'0 0 * * *' — midnight every day. '0 * * * *' — at the start of every hour. '*/15 * * * *' — every 15 minutes. '0 9 * * 1-5' — 9am Monday through Friday. '0 0 1 * *' — midnight on the first day of every month. '0 0 * * 0' — midnight every Sunday.
The step notation (/) is particularly useful. '*/5 * * * *' means every 5 minutes. '0 */2 * * *' means every 2 hours on the hour. '0 9-17 * * 1-5' means every hour from 9am to 5pm on weekdays.
- 0 0 * * * — every day at midnight
- 0 * * * * — every hour
- */15 * * * * — every 15 minutes
- 0 9 * * 1-5 — 9am weekdays
- 0 0 1 * * — first of every month at midnight
- 0 0 * * 0 — every Sunday at midnight
- 30 18 * * 1,3,5 — 6:30pm on Monday, Wednesday, Friday
Special strings and extensions
Many cron implementations support predefined special strings as shortcuts: @hourly (0 * * * *), @daily (0 0 * * *), @weekly (0 0 * * 0), @monthly (0 0 1 * *), @yearly (0 0 1 1 *), and @reboot (runs once at startup).
Some cloud schedulers (AWS EventBridge, GitHub Actions) use cron with a sixth field for seconds, or a different field order. AWS EventBridge, for example, uses six fields: minute, hour, day-of-month, month, day-of-week, year. Always check the documentation for the specific scheduler you're using.
Crontab files also include the command to run after the five fields: '0 0 * * * /usr/bin/backup.sh'. You can also set environment variables at the top of the crontab file.
Testing and debugging cron expressions
The best way to verify a cron expression is to check when it will next fire. Online cron expression testers show the next N execution times for any expression, which immediately reveals whether it does what you intend.
Common mistakes: forgetting that day-of-week and day-of-month combine with OR logic (if both are set to specific values, the job runs when either condition is true, not both). Using 0 for both Sunday and day-of-week position 0, which is fine. Forgetting that months are 1-indexed while minutes and hours start at 0.
For server cron jobs, check that the server's timezone is what you expect. Cron uses the system timezone by default. A job scheduled at 9am UTC runs at a different local time depending on where you are.
