What Is Cron?
Cron is a time-based job scheduler built into Unix-like operating systems. It runs commands or scripts at specified intervals according to a schedule defined in a crontab (cron table). The name comes from Kronos, the Greek god of time.
The cron daemon reads crontab files and executes the scheduled commands at the right times. Almost every Linux server runs cron for tasks like log rotation, database backups, and cache invalidation.
The Five-Field Expression
A standard cron expression has five fields separated by spaces:
┌───────────── minute (0–59)
│ ┌─────────── hour (0–23)
│ │ ┌───────── day of month (1–31)
│ │ │ ┌─────── month (1–12)
│ │ │ │ ┌───── day of week (0–7, where 0 and 7 are Sunday)
│ │ │ │ │
* * * * * command
Each field can contain:
- A specific value:
5(exactly at minute 5) - A wildcard:
*(every minute/hour/day) - A range:
1-5(Monday through Friday) - A list:
1,3,5(Monday, Wednesday, Friday) - A step:
*/15(every 15 minutes),0-12/2(every even hour from 0 to 12)
Common Examples
# Every minute
* * * * *
# Every hour at minute 0
0 * * * *
# Every day at midnight
0 0 * * *
# Every Sunday at 3am
0 3 * * 0
# Every 15 minutes
*/15 * * * *
# Weekdays at 9am
0 9 * * 1-5
# First day of every month at noon
0 12 1 * *
# Every 6 hours
0 */6 * * *
Special Strings
Many cron implementations support shorthand strings:
| String | Equivalent |
|---|---|
@yearly |
0 0 1 1 * |
@monthly |
0 0 1 * * |
@weekly |
0 0 * * 0 |
@daily |
0 0 * * * |
@hourly |
0 * * * * |
@reboot |
Run once at startup |
Six-Field Expressions
Many modern schedulers (AWS EventBridge, Spring, Quartz) add a seconds field at the beginning:
* * * * * *
│ │ │ │ │ │
│ │ │ │ │ └── day of week
│ │ │ │ └──── month
│ │ │ └────── day of month
│ │ └──────── hour
│ └────────── minute
└──────────── second
This is a source of common confusion — whether your scheduler expects 5 or 6 fields matters.
Common Pitfalls
Day of month + day of week. When both fields are non-wildcards, most cron implementations run the job when either condition is true, not both. Use * in one field to avoid ambiguity.
Timezone. Cron runs in the server's local timezone unless configured otherwise. If your server and your users are in different timezones, calculate accordingly.
Environment. The cron environment is minimal — your PATH, HOME, and other variables may not be set. Use absolute paths in cron commands.
Missed jobs. Standard cron does not "catch up" on jobs missed while the system was down. Use tools like cronie with anacron if you need this behaviour.
Try It
The Cron Parser on Syntaxly takes any cron expression and shows you exactly when the next several runs will occur, in plain English.