Cron Expression Guide: 5-Field Syntax + Real-World Examples
Almost every server-side scheduled task — log rotation, database backups, email reminders, daily reports — runs on cron. But the syntax can be cryptic: a string of * * * * * leaves many developers staring blankly.
📌 Key Takeaways
- Cron Expression Guide: 5-Field Syntax + Real-World is widely used by developers
- Based on RFC standards and real-world experience
- Free online tools, runs locally, no data upload
- FAQ section at the bottom answers common questions
📌 Key Takeaways
- Cron Expression Guide: 5-Field Syntax + Real-World is widely used by developers
- Based on RFC standards and real-world experience
- Free online tools, runs locally, no data upload
- FAQ section at the bottom answers common questions
This guide explains the 5-field cron syntax, special characters, the 6-field variant (with seconds), and 10 real-world examples. Use our online Cron Parser to verify your expressions instantly.
1. What a Cron Expression Looks Like
Standard cron has 5 fields (some systems support 6 with seconds), left to right: minute, hour, day-of-month, month, day-of-week. Each field separated by a space.
* * * * *
│ │ │ │ │
│ │ │ │ └─ Day of week (0-6, 0=Sunday)
│ │ │ └─── Month (1-12)
│ │ └───── Day of month (1-31)
│ └─────── Hour (0-23)
└───────── Minute (0-59)
Classic example: 0 2 * * * means every day at 2:00 AM. First field 0 = minute 0, second field 2 = hour 2, the three * = any value.
2. 9 Essential Special Characters
| Char | Meaning | Example |
|---|---|---|
* | Any value (every) | * = every minute |
, | List separator | 1,15 = 1 and 15 |
- | Range | 9-17 = 9 through 17 |
/ | Step (every N) | */10 = every 10 minutes |
? | No specific value | 0 0 ? * 1 = every Monday |
L | Last day | L = last day of month |
W | Nearest weekday | 15W = nearest weekday to the 15th |
# | Nth occurrence | 5#2 = 2nd Friday |
@ | Preset alias | @daily = 0 0 * * * |
3. 6-Field / 7-Field Cron (Seconds & Year)
Standard Unix cron is 5 fields, but Quartz (Java), Spring, AWS EventBridge use 6 or 7 fields — adding seconds at the front and optionally year at the end:
0 0 2 * * * (6-field: sec min hour day month weekday)
0 0 2 * * * 2026 (7-field: add year)
Always check your target system — "every day at 2 AM" is 0 2 * * * in Linux crontab but 0 0 2 * * ? in Spring @Scheduled.
4. 10 Real-World Examples
Ops / Backup
- Health check every 5 min:
*/5 * * * * - Daily backup at 2 AM:
0 2 * * * - Log cleanup every Sunday 3 AM:
0 3 * * 0 - Monthly report on the 1st:
0 1 1 * * - Weekday daily report at 11 PM:
0 23 * * 1-5
Business / Data
- Hourly data sync:
0 * * * * - Order pull every 15 min:
*/15 * * * * - Push every 30 min, 9 AM–6 PM:
*/30 9-18 * * * - Mon/Wed/Fri reminder at 8:30 AM:
30 8 * * 1,3,5 - Last day of month cleanup at 23:59:
59 23 L * *
5. 3 Common Pitfalls
Pitfall 1: Specifying both day-of-month and day-of-week. Cron treats them as OR — if either matches, the job fires. Use ? as a no-op in Quartz.
Pitfall 2: Forgetting timezone. Server default is often UTC. 0 9 * * * on a UTC server fires at 9 AM UTC, not 9 AM local time. Always check timedatectl.
Pitfall 3: Missing environment variables. Cron runs with a minimal environment — no ~/.bashrc. Use absolute paths or source /etc/profile at the top of your script.
6. Verify with Our Online Tool
The worst feeling: writing a cron expression, deploying it, and waiting a day to see if it fired. Use the DevToolbox Cron Parser:
- Enter an expression → see a human-readable explanation
- Preview the next 5 execution times
- Toggle between 5-field and 6-field modes
- Fully client-side — no data leaves your browser
7. Summary
Cron isn't hard — it's just symbols. Memorize * , - / ? L and follow the three-step workflow: pick a template → verify with the parser → write to crontab. For complex scheduling (dynamic cron, cross-timezone coordination), reach for Airflow / Temporal.
Related tools: Cron Parser · UUID Generator · Base64 Encoder