The Five Fields
ββββββββββββββ minute (0β59)
β ββββββββββββββ hour (0β23)
β β ββββββββββββββ day of month (1β31)
β β β ββββββββββββββ month (1β12 or JANβDEC)
β β β β ββββββββββββββ day of week (0β6, Sun=0, or SUNβSAT)
β β β β β
* * * * *
Special Characters
| Char | Name | Meaning | Example |
|---|
* | Wildcard | Any value | * * * * * β every minute |
, | List | Multiple values | 1,15 * * * * β at minute 1 and 15 |
- | Range | Inclusive range | 0 9-17 * * * β hours 9 through 17 |
/ | Step | Every Nth value | */5 * * * * β every 5 minutes |
? | No value | Skip this field | 0 0 ? * MON β (Quartz/AWS only) |
L | Last | Last day | 0 0 L * * β last day of month (Quartz) |
W | Weekday | Nearest weekday | 0 0 15W * * β nearest weekday to 15th (Quartz) |
# | Nth weekday | Nth occurrence | 0 0 ? * 5#3 β 3rd Friday (Quartz) |
Field Ranges
| Field | Allowed Values | Allowed 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 (0=Sunday) | , - * / ? L # |
Common Schedules
| Expression | Description |
|---|
* * * * * | Every minute |
*/5 * * * * | Every 5 minutes |
*/15 * * * * | Every 15 minutes |
*/30 * * * * | Every 30 minutes |
0 * * * * | Every hour (at :00) |
0 */2 * * * | Every 2 hours |
0 */6 * * * | Every 6 hours |
0 0 * * * | Daily at midnight |
0 6 * * * | Daily at 6:00 AM |
0 9 * * 1-5 | Weekdays at 9:00 AM |
0 9,18 * * * | Daily at 9 AM and 6 PM |
0 0 * * 0 | Every Sunday at midnight |
0 0 * * 1 | Every Monday at midnight |
0 0 1 * * | First of every month at midnight |
0 0 1,15 * * | 1st and 15th at midnight |
0 0 1 1 * | January 1st at midnight (yearly) |
30 2 * * 0 | Every Sunday at 2:30 AM |
Crontab Shortcuts
These shortcuts work in Linux/macOS crontab:
| Shortcut | Equivalent | Description |
|---|
@reboot | β | Run once at startup |
@yearly | 0 0 1 1 * | Once a year (Jan 1) |
@annually | 0 0 1 1 * | Same as @yearly |
@monthly | 0 0 1 * * | Once a month (1st) |
@weekly | 0 0 * * 0 | Once a week (Sunday) |
@daily | 0 0 * * * | Once a day (midnight) |
@midnight | 0 0 * * * | Same as @daily |
@hourly | 0 * * * * | Once an hour (:00) |
Day of Week Numbering
| Day | Standard cron | Quartz / Spring |
|---|
| Sunday | 0 (or 7) | 1 |
| Monday | 1 | 2 |
| Tuesday | 2 | 3 |
| Wednesday | 3 | 4 |
| Thursday | 4 | 5 |
| Friday | 5 | 6 |
| Saturday | 6 | 7 |
| Platform | Fields | Seconds? | Timezone | Notes |
|---|
| Linux crontab | 5 | No | System TZ | Supports @shortcuts |
| Kubernetes CronJob | 5 | No | UTC (default) | timeZone field since v1.27 |
| GitHub Actions | 5 | No | UTC only | Min 5-min interval; best-effort timing |
| GitLab CI | 5 | No | Configurable | Set in pipeline schedule UI |
| AWS EventBridge | 6 | No (year field) | UTC or specified | Uses ?; format: cron(0 9 ? * MON *) |
Spring @Scheduled | 6 | Yes (first field) | App TZ | 0 0 9 * * MON-FRI (note: seconds first) |
| Quartz | 6β7 | Yes (first field) | App TZ | Supports L, W, #, ? |
Common Mistakes
| Mistake | Why Itβs Wrong | Fix |
|---|
* * * * * when you meant hourly | Fires every minute (1440Γ/day) | 0 * * * * |
0 0 * * 1-7 | Day 7 is also Sunday (duplicate) | 0 0 * * 0-6 or 1-7 depending on system |
| Both DOM and DOW set | Standard cron uses OR logic | Set one to *; use ? in Quartz |
*/7 expecting βevery 7 minβ evenly | Fires at 0,7,14,21,28,35,42,49,56 (9Γ not 8Γ) | This is correct but uneven across hours |
| Forgetting Spring starts with seconds | 0 * * * * = every minute in Spring | Prepend 0: 0 0 * * * * |
Using @hourly in Kubernetes | Not supported; use 0 * * * * | K8s only accepts 5-field expressions |
Quick Examples by Use Case
Backups:
- Full backup nightly at 3 AM:
0 3 * * *
- Incremental every 6 hours:
0 */6 * * *
- Weekly full on Sunday 2 AM:
0 2 * * 0
Monitoring:
- Health check every 5 min:
*/5 * * * *
- Disk space alert every hour:
0 * * * *
- SSL cert check weekly:
0 9 * * 1
Reports:
- Daily digest at 8 AM:
0 8 * * *
- Weekly report Monday 9 AM:
0 9 * * 1
- Monthly billing on the 1st:
0 8 1 * *
Maintenance:
- Log cleanup daily at 4 AM:
0 4 * * *
- Cache flush every 15 min:
*/15 * * * *
- DB vacuum on Sunday 3 AM:
0 3 * * 0