Cron expressions are the standard way to schedule recurring tasks on Unix/Linux systems. This guide covers the most common cron patterns with ready-to-use examples.
Cron Syntax Overview
A standard cron expression has 5 fields:
ββββββββββββββ Minute (0-59)
β ββββββββββββ Hour (0-23)
β β ββββββββββ Day of month (1-31)
β β β ββββββββ Month (1-12)
β β β β ββββββ Day of week (0-7, where 0 and 7 = Sunday)
β β β β β
* * * * * command_to_executeQuick Reference: Common Cron Expressions
| Expression | Description |
|---|---|
* * * * * | Every minute |
*/5 * * * * | Every 5 minutes |
*/15 * * * * | Every 15 minutes |
*/30 * * * * | Every 30 minutes |
0 * * * * | Every hour (at minute 0) |
0 */2 * * * | Every 2 hours |
0 */6 * * * | Every 6 hours |
0 0 * * * | Daily at midnight |
0 6 * * * | Daily at 6:00 AM |
30 8 * * * | Daily at 8:30 AM |
0 0 * * 0 | Weekly (Sunday midnight) |
0 9 * * 1 | Every Monday at 9:00 AM |
0 9 * * 1-5 | Weekdays at 9:00 AM |
0 0 1 * * | First of every month (midnight) |
0 0 1 1 * | January 1st (midnight) |
0 0 1 */3 * | Every 3 months (quarterly) |
0 0 * * 1,4 | Monday and Thursday at midnight |
0 8-17 * * 1-5 | Every hour 8AM-5PM, weekdays |
Special Characters Explained
*β * (asterisk) β Matches every possible value for that field/β / (slash) β Step value. */5 means "every 5 units",β , (comma) β List of values. 1,3,5 means "1, 3, and 5"-β - (dash) β Range. 1-5 means "1 through 5"
Examples with special characters:
# Every 5 minutes
*/5 * * * *
# At minutes 0, 15, 30, 45 of every hour
0,15,30,45 * * * *
# Every weekday (Monday-Friday) at 9 AM
0 9 * * 1-5
# Every Monday and Friday at 6 PM
0 18 * * 1,5
# Every 3 hours on weekdays
0 */3 * * 1-5Platform Differences
Standard cron (crontab): 5 fields (minute hour day month weekday)
*/5 * * * * /path/to/script.shAWS CloudWatch/EventBridge: 6 fields, adds year; uses "?" for day-of-week or day-of-month
cron(0/5 * * * ? *)GitHub Actions: Standard 5 fields in schedule.cron, uses UTC
schedule:
- cron: '*/5 * * * *'Kubernetes CronJob: Standard 5 fields
spec:
schedule: "*/5 * * * *"Common Mistakes to Avoid
- Forgetting timezone β Cron runs in the system timezone unless configured otherwise. CI/CD platforms often use UTC.
- Using * * * * * (every minute) β This runs 1,440 times per day. Make sure you mean it!
- Confusing day-of-week values β Sunday is 0 (or 7) in standard cron, but 1 in some systems.
- Not logging output β Redirect stdout/stderr: */5 * * * * /script.sh >> /var/log/cron.log 2>&1
- Overlapping runs β If a job takes longer than the interval, use flock or a lock file.
Test your cron expressions interactively
Cron Expression Parser βFAQ
How do I schedule a cron job every 5 minutes?
Use */5 * * * * β the */5 in the minute field means "every 5th minute".
What does 0 0 * * * mean?
It runs at midnight (00:00) every day. The first 0 is the minute, the second 0 is the hour.
How do I run a cron job every Monday at 9am?
Use 0 9 * * 1 β minute=0, hour=9, any day, any month, weekday=1 (Monday).
What is the difference between */5 and 0/5?
In standard cron they are equivalent β both mean "every 5th minute". Some platforms like AWS support 0/5 syntax specifically.
Can I specify both day-of-month and day-of-week?
In standard cron, if both are set (not *), the job runs when EITHER matches. AWS CloudWatch requires "?" for one of them.