Cron Expressions Explained: A Complete Reference
Cron is the Unix job scheduler, and cron expressions are the scheduling language it uses. Mastering them unlocks reliable automation across Linux servers, CI/CD pipelines (GitHub Actions, GitLab CI), cloud platforms (AWS EventBridge, Google Cloud Scheduler), and application frameworks. The syntax is concise but packed with edge cases that catch developers off guard.
Parse and explain any cron expression: Our Cron Parser explains expressions in plain English and shows the next 5 scheduled run times.
Open Cron Parser โTable of Contents
The Five Fields
A standard cron expression has five space-separated fields:
โโโโโโโโโโโโโโโโ minute (0โ59)
โ โโโโโโโโโโโโโโ hour (0โ23)
โ โ โโโโโโโโโโโโ day of month (1โ31)
โ โ โ โโโโโโโโโโ month (1โ12)
โ โ โ โ โโโโโโโโ day of week (0โ7, 0 and 7 are both Sunday)
โ โ โ โ โ
* * * * *
Operators
| Operator | Meaning | Example |
|---|---|---|
* | Every valid value | * * * * * โ every minute |
, | List of values | 0,15,30,45 * * * * โ every 15 min |
- | Range of values | 0 9-17 * * 1-5 โ every hour 9amโ5pm weekdays |
/ | Step values | */5 * * * * โ every 5 minutes |
Common Patterns
# Every minute
* * * * *
# Every hour (at :00)
0 * * * *
# Every 6 hours
0 */6 * * *
# Daily at midnight UTC
0 0 * * *
# Daily at 9 AM
0 9 * * *
# Weekdays at 9 AM (Monday=1, Friday=5)
0 9 * * 1-5
# Every 15 minutes
*/15 * * * *
# Every 30 minutes between 9am and 5pm on weekdays
*/30 9-17 * * 1-5
# First day of each month at midnight
0 0 1 * *
# Last day of month (not directly supported โ use application logic)
# Workaround: run daily and check date in the script
# Every Sunday at 2 AM
0 2 * * 0
# January 1st at midnight
0 0 1 1 *
# Multiple specific times: 9 AM and 5 PM weekdays
0 9,17 * * 1-5
The Day-of-Week Gotcha
When both day-of-month and day-of-week are specified (not *), most cron implementations use OR logic โ the job runs if EITHER condition is true. Setting 0 0 15 * 1 runs on the 15th of every month and every Monday โ not "every Monday the 15th". To express the latter, check the date inside your script.
Platform Differences
| Platform | Fields | Notes |
|---|---|---|
| Standard cron | 5 fields | Minute through day-of-week |
| Spring @Scheduled | 6 fields | Adds seconds as first field |
| AWS EventBridge | 6 fields | Adds year as last field; uses ? for "no specific value" |
| GitHub Actions | 5 fields | Standard cron, runs in UTC |
| Kubernetes CronJob | 5 fields | Standard cron |
Timezone Considerations
Traditional cron runs in the server's local timezone. Managed services vary: GitHub Actions uses UTC, AWS EventBridge supports timezone specification, Google Cloud Scheduler allows any IANA timezone. Always document which timezone your cron expressions assume. Convert to UTC for cross-region deployments.
Common Scheduling Recipes
# Database backup โ every day at 2 AM
0 2 * * *
# Weekly report email โ every Monday at 8 AM
0 8 * * 1
# Clear temp files โ every hour
0 * * * *
# Health check โ every 5 minutes
*/5 * * * *
# End-of-month billing โ 1st of month at 6 AM
0 6 1 * *
# Quarter-hour during business hours
*/15 9-17 * * 1-5
# Cache warmup โ every night at 11:30 PM
30 23 * * *
Testing Cron Expressions
Before deploying a scheduled job, always verify the expression produces the times you expect. Calculate the next 5โ10 run times and check they match your intent. The most common mistake is forgetting that */6 in the hours field runs at 0, 6, 12, and 18 โ not at 6-hour intervals from "now". Similarly, 0 9 * * 1-5 runs at exactly 9:00 AM Monday through Friday โ not every hour between Monday and Friday.
