6 min read
Understanding Cron Expressions: A Complete Guide
Cron is a time-based job scheduler in Unix-like computer operating systems. For decades, developers have used it to automate system maintenance or administration, but its syntax remains a common source of confusion.
The Structure of a Cron Expression
A standard cron expression consists of five fields separated by white space. Each field represents a specific unit of time:
| Field | Allowed Values | Special Characters |
|---|---|---|
| Minute | 0-59 | * , - / |
| Hour | 0-23 | * , - / |
| Day of Month | 1-31 | * , - / ? L W |
| Month | 1-12 or JAN-DEC | * , - / |
| Day of Week | 0-6 or SUN-SAT | * , - / ? L # |
Special Characters Explained
*(Asterisk)
Specifies all values. For example, an asterisk in the minute field means "every minute".
,(Comma)
Separates items in a list. For example, 1,3,5 in the day of week field means "Monday, Wednesday, and Friday".
/(Slash)
Specifies increments. For example, */15 in the minute field means "every 15 minutes".
Common Cron Examples
0 0 * * *- Run at midnight every day.0 12 * * MON-FRI- Run at noon every weekday.*/5 * * * *- Run every 5 minutes.0 0 1 * *- Run at midnight on the first day of every month.
Stop Guessing Your Cron Jobs
Writing cron expressions by hand is error-prone. Use our visual generator to build and validate your cron jobs instantly.
Open Cron Generator