Complete Guide to Cron Expressions & Scheduling
Cron is the time-based job scheduler that powers automation across Unix, Linux, macOS, cloud platforms, and CI/CD pipelines. If you have ever needed to run a script at midnight, send a report every Monday, or clean up logs every hour, you have used cron.
1. Anatomy of a Cron Expression
A standard cron expression has five fields separated by spaces: minute (0-59), hour (0-23), day of month (1-31), month (1-12), and day of week (0-6, where 0 is Sunday). Each field can be a specific value, a range, a list, a step, or a wildcard.
The five fields answer the question: at what minute, of what hour, on what day of the month, in what month, on what day of the week should this job run?
2. Special Characters
- * (asterisk): Matches every possible value. * in the hour field means every hour.
- / (slash): Step values. */5 in minutes means every 5 minutes. */2 in hours means every 2 hours.
- - (dash): Ranges. 9-17 in hours means 9 AM through 5 PM. 1-5 in day-of-week means Monday through Friday.
- , (comma): Lists. 1,15 in day-of-month means the 1st and 15th. 0,30 in minutes means on the hour and half hour.
3. Common Cron Schedules
- Every minute: * * * * *
- Every 5 minutes: */5 * * * *
- Every hour on the hour: 0 * * * *
- Daily at midnight: 0 0 * * *
- Weekdays at 9 AM: 0 9 * * 1-5
- First of every month: 0 0 1 * *
- Every Sunday at 2 AM: 0 2 * * 0
4. Common Gotchas
Day-of-month AND day-of-week
When both day-of-month and day-of-week are set to non-* values, most cron implementations use OR logic — the job runs when either condition is met. This catches many people off guard. 0 0 15 * 5 means midnight on the 15th OR every Friday, not the 15th only if it is Friday.
Environment variables
Cron jobs run with a minimal environment — your PATH, HOME, and other variables may not be set. Always use absolute paths in cron scripts and source your profile if needed.
Percent signs end the command
In a crontab line, an unescaped % is turned into a newline and everything after the first one is sent to the command as standard input (crontab(5)). So 0 1 * * * tar czf /backup/$(date +%F).tgz /srv silently breaks. Escape it as \%F, or move the command into a script.
Daylight-saving changes
Debian's cron(8) documents what happens when the clock jumps by less than three hours: jobs whose time was skipped in the spring run soon after the change, and jobs in the repeated hour in the autumn are not run twice; wildcard jobs simply follow the new time. Our test below shows the spring case: on March 8, 2026 in New York, a 02:30 daily job fires at 03:00 EDT, the moment the clock jumps. If a job must not run twice or late, schedule it outside 01:00–03:00 local time or run the server in UTC.
4b. Worked Example: The Guide's Expressions, Checked
We ran the expressions from this guide through the cron engine behind our Crontab Explainer and through croniter 6.2.4 (Python), from March 6, 2026, America/New_York. Both gave identical times (script and results in our test folder, October 13, 2026):
| Expression | Next runs (local time) | What it shows |
|---|---|---|
0 0 15 * 5 | Fri Mar 6, Fri Mar 13, Sun Mar 15, Fri Mar 20, Fri Mar 27 | Day-of-month and day-of-week are ORed: every Friday plus the 15th |
0 9 * * 1-5 | Fri Mar 6, Mon Mar 9 … Fri Mar 13, Mon Mar 16 | Weekend skipped; 09:00 stays 09:00 across the DST change (14:00 → 13:00 UTC) |
30 2 * * * | 02:30 Mar 6–7, 03:00 Mar 8, 02:30 Mar 9 onward | The skipped 02:30 runs at the jump |
4c. Same Five Fields, Different Rules
"Cron syntax" means slightly different things on each platform. Before copying an expression between them, check these differences (from each platform's documentation, checked October 13, 2026):
| Platform | Fields | Time zone | Notable rules |
|---|---|---|---|
| Vixie cron / cronie (Linux) | 5 | System local time | 0 and 7 both mean Sunday; DOM/DOW ORed; % is special |
| GitHub Actions schedule | 5 (POSIX) | UTC by default; an IANA timezone can be set | Shortest interval every 5 minutes; runs on the latest commit of the default branch; with a DST zone, runs in a skipped hour move to the next valid time |
| AWS EventBridge Scheduler | 6, wrapped as cron(...) | Set per schedule | Adds a year field; day-of-week is 1–7 starting with Sunday = 1; supports L, W, # and ? wildcards |
| Kubernetes CronJob | 5 | .spec.timeZone, else the controller's local zone | CRON_TZ/TZ inside the schedule is not supported |
The day-of-week trap is the costly one: 0 9 * * 1 is Monday in Linux cron and GitHub Actions, but in AWS's six-field format Monday is 2.
5. Cron Best Practices
- Log everything: Redirect stdout and stderr to a log file. Silent failures are the worst kind.
- Use lock files: Prevent overlapping runs with flock or a PID file, especially for long-running jobs.
- Test at a safe frequency first: Start with */5 * * * * (every 5 minutes) to verify the job works before setting the final schedule.
- Document your crontab: Add comments above each entry explaining what the job does and who owns it.
- [1]Debian manpages: crontab(5) — fields, DOM/DOW OR rule, % handling, 0 and 7 = Sunday (bookworm) ↗
- [2]Debian manpages: cron(8) — clock changes under 3 hours (daylight saving) ↗
- [3]GitHub Docs: events that trigger workflows — schedule (UTC default, timezone, 5-minute minimum) ↗
- [4]AWS EventBridge Scheduler User Guide: schedule types — cron expressions (six fields, day-of-week 1–7) ↗
- [5]Kubernetes documentation: CronJob — time zones ↗
- [6]croniter on PyPI (version 6.2.4 used for the cross-check) ↗