Cron Expressions: A Complete Reference with 30+ Examples
Master cron syntax for Linux, GitHub Actions, Kubernetes CronJobs, AWS EventBridge, and Spring/Quartz. Full field reference and gotchas.
By Belqassim Djafer · Published · Updated
What is a Cron Expression?
Cron is a Unix utility for scheduling commands at specified times. A cron expression is a string of fields defining a schedule:
┌─────────── minute (0–59)
│ ┌──────── hour (0–23)
│ │ ┌───── day of month (1–31)
│ │ │ ┌── month (1–12)
│ │ │ │ ┌─ day of week (0–7, Sunday = 0 or 7)
* * * * *
Special Characters
| Char | Meaning | Example |
|---|---|---|
* |
Any value | * * * * * = every minute |
, |
List | 0 9,17 * * * = 9AM and 5PM |
- |
Range | 0 9-17 * * * = every hour 9–17 |
/ |
Step | */15 * * * * = every 15 minutes |
L |
Last (Quartz) | 0 0 L * * = last day of month |
# |
Nth weekday | 0 9 * * 2#1 = first Tuesday |
30 Real-World Examples
# Every N minutes
*/5 * * * * # Every 5 minutes
*/15 * * * * # Every 15 minutes
*/30 * * * * # Every 30 minutes
# Hourly / Daily
0 * * * * # Every hour
0 0 * * * # Every day at midnight
0 6 * * * # Every day at 6 AM
0 8,20 * * * # Twice daily: 8 AM and 8 PM
# Weekday schedules
0 9 * * 1-5 # Every weekday at 9 AM
0 17 * * 1-5 # Every weekday at 5 PM
0 10 * * MON # Every Monday at 10 AM
0 0 * * 0 # Every Sunday at midnight
# Monthly / quarterly
0 0 1 * * # First day of every month
0 0 15 * * # 15th of every month
0 0 1 1,4,7,10 * # First day of each quarter
# CI/CD and maintenance
0 2 * * * # Nightly backup at 2 AM
0 3 * * 0 # Weekly cleanup Sunday at 3 AM
0 4 1 * * # Monthly report on the 1st
*/10 9-17 * * 1-5 # Every 10 min during business hours
Platform Differences
Linux cron
Standard 5-field syntax. Special strings available:
@hourly @daily @weekly @monthly @yearly @reboot
GitHub Actions
UTC timezone. Minimum interval: 5 minutes (may be delayed at off-peak hours).
on:
schedule:
- cron: '0 2 * * *' # Every day at 02:00 UTC
- cron: '0 9 * * 1' # Every Monday at 09:00 UTC
Kubernetes CronJob
spec:
schedule: "0 2 * * *"
concurrencyPolicy: Forbid # prevents overlapping executions
AWS EventBridge
Uses 6-field Quartz syntax. Year is optional 7th field. Exactly one of DOM or DOW must be ?:
cron(0 12 * * ? *) # Every day at 12:00 UTC
cron(0 8 ? * MON-FRI *) # Weekdays at 8:00 UTC
Spring / Quartz
6-field: seconds first. S M H DOM MON DOW [YEAR]
@Scheduled(cron = "0 0 9 * * MON-FRI") // 9 AM weekdays
@Scheduled(cron = "0 */30 * * * *") // Every 30 seconds
Common Mistakes
DOM + DOW = OR, not AND
If both DOM and DOW are set, the job runs when either condition is true — not both:
0 0 1 * MON # Runs on the 1st of every month, PLUS every Monday (OR)
Timezone Assumptions
Linux cron uses system timezone. GitHub Actions, AWS, and Kubernetes use UTC. Always document your timezone assumption.
Missed Executions
If the system is down when a job was scheduled, the job is skipped. Use startingDeadlineSeconds in Kubernetes CronJobs to control catch-up behavior.
Overlapping Executions
If a job takes longer than its interval, multiple instances can run simultaneously. Always add a distributed lock or use concurrencyPolicy: Forbid.
Conclusion
Cron expressions are a fundamental skill for backend and DevOps engineers. The core syntax is simple; platform variations (AWS 6-field, Quartz seconds-first) are the main source of confusion. Test expressions before deploying to production.
Use the Cron Expression Builder to visually build and validate cron expressions for any platform.