Cron Expression Format
A standard cron expression has five fields: minute (0–59), hour (0–23), day of month (1–31), month (1–12), and day of week (0–6, Sunday=0). An asterisk (*) means “every.” Examples: 0 9 * * 1-5 runs at 9:00 AM every weekday; */15 * * * * runs every 15 minutes.
Special Characters
Comma (,) lists specific values: 1,15,30 means the 1st, 15th, and 30th minute. Hyphen (-) defines a range: 9-17 means hours 9 through 17. Slash (/) steps through values: */5 means every 5 units. Some implementations add a seconds field—verify which format your scheduler expects before deploying.
Common Pitfalls
When both day-of-month and day-of-week are set, most cron daemons use OR logic—the job runs if either condition is true. Scheduling many jobs at :00 creates server-wide load spikes; offset recurring jobs by a few minutes (e.g., 3, 17, 33, 47) to spread the load across the hour.
Frequently Asked Questions
Is 0 or 7 Sunday?
Both. In standard Unix cron, 0 and 7 both represent Sunday in the day-of-week field, and most implementations accept either value. However, some schedulers number differently — Quartz Scheduler uses 1–7 (Sunday=1, Saturday=7). Always verify with your specific platform’s documentation; a job intended for Sunday can silently run on Saturday if the numbering scheme differs.
What about seconds in cron expressions?
Standard Unix cron has 5 fields (minute, hour, day-of-month, month, day-of-week) with 1-minute minimum resolution. For second-level scheduling, use Quartz cron (6 fields, adds seconds at position 0), systemd timers, or platform-specific extended syntax like AWS EventBridge. Always check your scheduler’s documentation before assuming the 5-field standard applies.