Cron Jobs: The Complete Developer Reference
Cron Syntax Explained: All 5 Fields
The standard cron format has exactly 5 space-separated fields:
[minute] [hour] [day-of-month] [month] [day-of-week]
Field ranges:
- Minute: 0β59
- Hour: 0β23 (24-hour clock)
- Day of month: 1β31
- Month: 1β12 (or JANβDEC)
- Day of week: 0β7 (0 and 7 both = Sunday, or SUNβSAT)
Special characters:
- * β every value
- */n β every n-th value (e.g., */5 for every 5 minutes)
- a-b β range (e.g., 1-5 for MonβFri)
- a,b,c β list (e.g., 1,15 for the 1st and 15th)
- L β last (e.g., L in day-of-month = last day of month, not all systems support this)
20 Essential Cron Patterns Every Developer Should Know
Here are the most commonly used cron patterns:
* * * * *β Every minute*/5 * * * *β Every 5 minutes0 * * * *β Every hour (on the hour)0 0 * * *β Every day at midnight0 9 * * *β Every day at 9:00 AM0 9 * * 1β Every Monday at 9:00 AM0 9-17 * * 1-5β Every hour from 9 AM to 5 PM, MonβFri0 0 1 * *β First day of every month at midnight0 0 L * *β Last day of every month (Linux cron)0 0 * * 0β Every Sunday at midnight30 23 * * *β Every day at 11:30 PM0 */6 * * *β Every 6 hours0 0 1 1 *β January 1st at midnight (New Year's reset)*/15 9-17 * * 1-5β Every 15 min during business hours0 2 * * *β Every night at 2:00 AM (common for backups)
Cron Across Different Platforms: Key Differences
Cron syntax varies between platforms β watch for these differences:
Linux/Unix crontab: Standard 5-field format. Supports @reboot, @daily, @hourly shortcuts.
AWS EventBridge / CloudWatch: Uses 6-field format with year: cron(0 9 ? * MON-FRI *). Also uses ? for 'no specific value' in day fields.
Spring Framework (@Scheduled): 6-field with seconds first: 0 0 9 * * MON-FRI.
GitHub Actions: Uses standard 5-field cron syntax in schedule: triggers. Runs in UTC.
Kubernetes CronJobs: Standard 5-field. Timezone support was added in Kubernetes 1.27 with timeZone field.
Always test cron expressions in a staging environment. An off-by-one in the hour field can cause jobs to run at 3 AM instead of 9 AM.