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.

✍️ Author:DevToolbox Team📅 Updated:2026-06-24📎 References:Wikipedia: Cron expression reference
Quartz Scheduler Cron tutorialRFC Standards

📌 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
✍️ Author:DevToolbox Team📅 Updated:2026-06-24

📌 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 separator1,15 = 1 and 15
-Range9-17 = 9 through 17
/Step (every N)*/10 = every 10 minutes
?No specific value0 0 ? * 1 = every Monday
LLast dayL = last day of month
WNearest weekday15W = nearest weekday to the 15th
#Nth occurrence5#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

  1. Health check every 5 min: */5 * * * *
  2. Daily backup at 2 AM: 0 2 * * *
  3. Log cleanup every Sunday 3 AM: 0 3 * * 0
  4. Monthly report on the 1st: 0 1 1 * *
  5. Weekday daily report at 11 PM: 0 23 * * 1-5

Business / Data

  1. Hourly data sync: 0 * * * *
  2. Order pull every 15 min: */15 * * * *
  3. Push every 30 min, 9 AM–6 PM: */30 9-18 * * *
  4. Mon/Wed/Fri reminder at 8:30 AM: 30 8 * * 1,3,5
  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

FAQ: Common Questions

Q: What are cron expressions?

Cron is a scheduled task scheduler for Unix systems. The 5-6 fields in the expression represent time (hour, day, month, week). For example `0 9 * * 1-5` = 9am on a weekday.

Q: How to write Cron expression?

5 fields: minutes (0-59) hours (0-23) days (1-31) months (1-12) weeks (0-6). Special characters: * any, , list, - range, / step. Example: */15 * * * * = every 15 minutes.

Q: What are the Cron expression debugging tools?

crontab.guru (Cron expression translator), DevToolbox Cron Parser (visual parsing). For complex scheduling, it is recommended to use systemd timer instead of Cron.

🧰
Add to Home Screen
Works offline, launches instantly