Understanding Linux Cron Syntax (5-Field Breakdown)
Cron is the standard Linux time-based job scheduler. A standard 5-field crontab expression follows this sequential structure:
┌───────────── Minute (0 - 59)
│ ┌───────────── Hour (0 - 23, 24-hr time)
│ │ ┌───────────── Day of Month (1 - 31)
│ │ │ ┌───────────── Month (1 - 12 or JAN - DEC)
│ │ │ │ ┌───────────── Day of Week (0 - 6 where 0 = Sunday, or SUN - SAT)
│ │ │ │ │
* * * * *
Linux Crontab 5-Field Reference Guide
| Field Position | Field Name | Allowed Values | Allowed Special Characters | Example Usage |
|---|---|---|---|---|
| 1st Field | Minute | 0 - 59 |
* , - / |
*/15 (every 15 mins), 0,30 |
| 2nd Field | Hour | 0 - 23 |
* , - / |
0 (midnight), 9-17 (work hours) |
| 3rd Field | Day of Month | 1 - 31 |
* , - / ? L W |
1 (first day), 1,15 (bimonthly) |
| 4th Field | Month | 1 - 12 or JAN - DEC |
* , - / |
* (every month), 1,4,7,10 (quarterly) |
| 5th Field | Day of Week | 0 - 6 (0=Sun) or SUN - SAT |
* , - / ? L # |
1-5 (Mon-Fri weekdays), 0,6 (weekends) |
Common Crontab Schedule Examples
| Cron Expression | Schedule Description | Frequency / Interval | Ideal Use Case |
|---|---|---|---|
* * * * * |
Runs every minute continuously | 1,440 times / day | High-frequency worker queue monitoring |
*/5 * * * * |
Runs every 5 minutes | 288 times / day | API heartbeat checks & cache warm-ups |
0 * * * * |
Runs at minute 0 of every hour | 24 times / day | Hourly metrics rollup & log rotation |
0 0 * * * |
Runs once daily at midnight (00:00) | 1 time / day | Daily database backup & cleanup tasks |
0 9 * * 1-5 |
Runs at 09:00 AM, Monday through Friday | 5 times / week | Business morning email summaries |
0 0 * * 0 |
Runs every Sunday at midnight (00:00) | 1 time / week | Weekly analytics report generation |
0 0 1 * * |
Runs on the 1st of every month at midnight | 1 time / month | Monthly customer billing & invoicing |
0 0 1 1,4,7,10 * |
Runs on the 1st day of every quarter | 4 times / year | Quarterly compliance audits & tax prep |
Understanding Cron Special Characters
- Asterisk (
*): Matches every possible value in the field (e.g.,*in hour means every hour). - Comma (
,): Specifies a discrete list of values (e.g.,1,15in Day of Month runs on the 1st and 15th). - Hyphen (
-): Defines an inclusive range of values (e.g.,1-5in Day of Week runs Monday through Friday). - Slash (
/): Denotes step values or intervals (e.g.,*/10in Minute means every 10 minutes).
Frequently Asked Questions (FAQ)
What is a standard 5-field Linux cron expression?
A standard 5-field Linux cron expression consists of Minute (0-59), Hour (0-23), Day of Month (1-31), Month (1-12), and Day of Week (0-6 where 0 is Sunday) separated by spaces. It defines exact schedules for automated background jobs in Linux crontab, Node.js, and cloud schedulers.
How do the 5 fields of a crontab schedule work?
The 5 fields evaluate in sequence: (1) Minute: 0-59; (2) Hour: 0-23 in 24-hour time; (3) Day of Month: 1-31; (4) Month: 1-12 (or JAN-DEC); (5) Day of Week: 0-6 (where 0 is Sunday, or SUN-SAT). An asterisk (*) means every possible value in that field.
What does */5 * * * * mean in cron syntax?
The slash operator (/) specifies step values. The expression '*/5 * * * *' runs the scheduled job every 5 minutes continuously throughout every hour, day, and month.
How do I schedule a job to run only on weekdays (Monday to Friday)?
Use '1-5' in the 5th field (Day of Week). For example, '0 9 * * 1-5' schedules the task to execute every weekday (Monday through Friday) at exactly 09:00 AM.
How do I test and verify the next execution times of a cron expression?
This tool automatically calculates and displays the Next 5 Scheduled Run Times in both your local system timezone and UTC, ensuring you never deploy an incorrect crontab schedule to production.