Cron Job Schedule Syntax Explained
A cron job schedule is a string of five (or sometimes six) fields that tells a Unix-like operating system exactly when to execute a command.
The Standard Five-Field Syntax
Each asterisk represents a specific unit of time. The order is always the same:
| Field | Definition | Allowed Values |
|---|---|---|
| 1 | Minute | 0 – 59 |
| 2 | Hour | 0 – 23 (0 is midnight) |
| 3 | Day of Month | 1 – 31 |
| 4 | Month | 1 – 12 (or JAN-DEC) |
| 5 | Day of Week | 0 – 6 (Sunday to Saturday) |
Understanding the Symbols
While the asterisk (*) is the most common symbol, there are others that allow for more complex scheduling:
*(Asterisk): Every. If you put*in the minute field, it means “every minute.”,(Comma): A list of values.1,15,30in the minute field means at the 1st, 15th, and 30th minute.-(Hyphen): A range.1-5in the Day of Week field means Monday through Friday./(Slash): Increments.*/10in the minute field means “every 10 minutes.”
Common Examples
Here is how those symbols look in practice:
- 0 0 * * *
Runs at exactly midnight every single day. - */15 9-17 * * 1-5
Runs every 15 minutes during business hours (9 AM to 5 PM), Monday through Friday. - 0 12 1 * *
Runs at noon on the first day of every month. - 30 8 * * 0
Runs every Sunday at 8:30 AM.
A Note on the Sixth Field
In some systems (like Quartz or modern cloud schedulers), there might be a sixth field at the very beginning. This is usually for seconds (0-59). If the string has six parts, always check the documentation for that specific tool, as it usually shifts the other fields to the right.