Cron Syntax Cheat Sheet: 30 Examples and Common Gotchas
The five cron fields, 30 ready-made schedules, and the gotchas behind missed jobs, for crontab, Kubernetes, GitHub Actions and AWS.
Cron has scheduled jobs on Unix systems since the 1970s, and its five-field syntax is now everywhere: Linux crontabs, Kubernetes CronJobs, GitHub Actions, CI systems, cloud schedulers and countless libraries. It's compact, and easy to get subtly wrong. A job meant for "the first Monday of the month" that runs on the first and on every Monday is a classic.
This cheat sheet covers the syntax, the 30 schedules people search for most, the gotchas that cause real incidents, and how cron differs between Linux, Kubernetes, GitHub Actions and AWS.
The five fields
┌───────────── minute (0–59)
│ ┌─────────── hour (0–23)
│ │ ┌───────── day of month (1–31)
│ │ │ ┌─────── month (1–12 or JAN–DEC)
│ │ │ │ ┌───── day of week (0–6 or SUN–SAT; 7 is also Sunday)
│ │ │ │ │
* * * * * command to run
A job runs whenever the current time matches every field (with one important exception for the two day fields, explained below). Times use a 24-hour clock.
The four special characters
| Symbol | Meaning | Example | Reads as |
|---|---|---|---|
* | Every value | * * * * * | Every minute |
, | A list | 0 9,17 * * * | At 09:00 and 17:00 |
- | A range | 0 9-17 * * 1-5 | On the hour, 09:00 to 17:00, Monday to Friday |
/ | A step | */15 * * * * | Every 15 minutes (:00, :15, :30, :45) |
They combine: 0-30/10 is minutes 0, 10, 20 and 30, and 1-5,0 in the weekday field is Monday to Friday plus Sunday.
Paste any expression into the cron explainer to see it in plain English with its next run times, in your time zone or in UTC.
30 common schedules
Every few minutes or hours
| Schedule | Expression |
|---|---|
| Every minute | * * * * * |
| Every 5 minutes | */5 * * * * |
| Every 10 minutes | */10 * * * * |
| Every 15 minutes | */15 * * * * |
| Every 30 minutes | */30 * * * * |
| Every hour, on the hour | 0 * * * * |
| Every hour, at 30 past | 30 * * * * |
| Every 2 hours | 0 */2 * * * |
| Every 6 hours | 0 */6 * * * |
| Every 12 hours (midnight and noon) | 0 0,12 * * * |
Daily and weekly
| Schedule | Expression |
|---|---|
| Every day at midnight | 0 0 * * * |
| Every day at 02:30 | 30 2 * * * |
| Every day at 09:00 | 0 9 * * * |
| Twice a day, 08:00 and 20:00 | 0 8,20 * * * |
| Weekdays at 09:00 | 0 9 * * 1-5 |
| Weekends at 10:00 | 0 10 * * 6,0 |
| Every Monday at 08:00 | 0 8 * * 1 |
| Every Friday at 17:30 | 30 17 * * 5 |
| Every 15 minutes during office hours | */15 9-17 * * 1-5 |
| Every Sunday at 03:00 (maintenance) | 0 3 * * 0 |
Monthly and yearly
| Schedule | Expression |
|---|---|
| First day of every month at midnight | 0 0 1 * * |
| The 15th of every month at 12:00 | 0 12 15 * * |
| The 1st and 15th at 06:00 | 0 6 1,15 * * |
| Every quarter (Jan, Apr, Jul, Oct 1st) | 0 0 1 1,4,7,10 * |
| Every 3 months, the short way | 0 0 1 */3 * |
| Twice a year (Jan 1st and Jul 1st) | 0 0 1 1,7 * |
| Once a year, 1 January at midnight | 0 0 1 1 * |
| Every weekday in December at 09:00 | 0 9 * 12 1-5 |
| The last few days of a month (28th–31st) | 0 0 28-31 * * |
| Every minute of 25 December, for testing | * * 25 12 * |
Shortcuts
Most crons also understand these macros:
| Macro | Same as |
|---|---|
@hourly | 0 * * * * |
@daily or @midnight | 0 0 * * * |
@weekly | 0 0 * * 0 |
@monthly | 0 0 1 * * |
@yearly or @annually | 0 0 1 1 * |
@reboot | Once, when the cron daemon starts |
Six gotchas that cause real incidents
1. The day-of-month / day-of-week OR rule
When both day fields are restricted (neither is *), standard cron runs the job when either matches, not both:
0 9 1 * 1 # 09:00 on the 1st of the month AND every Monday, not "the 1st, if it's a Monday"
So there's no way to say "the first Monday of the month" in standard cron. The usual workaround is to run on days 1–7 and check the weekday in the command:
0 9 1-7 * * [ "$(date +\%u)" = 1 ] && /usr/local/bin/monthly-report
The cron explainer warns you when an expression falls into this trap.
2. Steps restart every hour, day or month
*/7 in the minute field doesn't mean "every 7 minutes forever". It means minutes 0, 7, 14 … 56, and then 0 again, so there's a 4-minute gap at the top of every hour. Steps only divide evenly when they fit the field: 1, 2, 3, 4, 5, 6, 10, 12, 15, 20 and 30 for minutes; 1, 2, 3, 4, 6, 8 and 12 for hours.
3. Which time zone?
Classic cron uses the server's local time zone. Many servers and containers run in UTC, so 0 9 * * * may fire at 17:00 in Malaysia (UTC+8). Check before you trust it:
- Linux:
timedatectlordateshows the zone. Some crons (such as cronie) accept aCRON_TZ=line in the crontab. - Kubernetes: set
spec.timeZoneon the CronJob (stable since Kubernetes 1.27). - GitHub Actions: schedules run in UTC by default.
- Cloud schedulers: most let you choose a time zone per job.
If your zone has daylight saving time, a job scheduled between 01:00 and 03:00 local time can be skipped or run twice on the nights the clocks change, depending on the implementation. Servers in UTC, or in zones without daylight saving such as Malaysia and Singapore, avoid this entirely.
4. Seconds (and other fields) don't exist in standard cron
Six- and seven-field expressions belong to other dialects:
- Quartz (Java) and Spring's
@Scheduledput seconds first:0 0 9 * * ?is 09:00 every day. - AWS EventBridge uses six fields with a year at the end and needs
?in one of the day fields:cron(0 9 ? * MON-FRI *). - Quartz-style crons also add
L(last),W(nearest weekday) and#(the nth weekday:MON#1is the first Monday).
Paste a six-field expression into a standard crontab and every field shifts by one: your "seconds" become minutes, and the schedule is silently wrong.
5. % means "new line" in a crontab
In a crontab line, an unescaped % ends the command, and everything after it is sent to the command as input. That breaks date +%Y-%m-%d. Escape it as \%, or move the command into a script.
6. Cron's environment is almost empty
Jobs run with a minimal PATH and none of your shell's settings, so a command that works in your terminal can fail under cron.
- Use absolute paths (
/usr/bin/python3, notpython3). - Set what you need at the top of the crontab (
PATH=…,SHELL=/bin/bash). - Capture output, or failures vanish:
>> /var/log/backup.log 2>&1.
Writing a crontab
Edit your user's crontab with crontab -e, and list it with crontab -l:
# m h dom mon dow command
PATH=/usr/local/bin:/usr/bin:/bin
# nightly database backup at 02:30, with a lock so runs never overlap
30 2 * * * flock -n /tmp/backup.lock /usr/local/bin/backup.sh >> /var/log/backup.log 2>&1
# clear temporary files every Sunday at 03:00
0 3 * * 0 find /var/app/tmp -type f -mtime +7 -delete
flock -n skips a run if the previous one is still going, which matters for any job that can take longer than its interval.
Kubernetes CronJob
apiVersion: batch/v1
kind: CronJob
metadata:
name: nightly-report
spec:
schedule: '30 2 * * *'
timeZone: 'Asia/Kuala_Lumpur'
concurrencyPolicy: Forbid # don't start a run while one is still going
jobTemplate:
spec:
template:
spec:
restartPolicy: OnFailure
containers:
- name: report
image: registry.example.com/report:1.4.2
GitHub Actions
on:
schedule:
- cron: '17 3 * * *' # 03:17 UTC every day
A few things to know about scheduled workflows:
- The shortest interval is every 5 minutes.
- Runs can be delayed at busy times, especially at the top of the hour. Picking an odd minute, like :17, helps.
- In public repositories, scheduled workflows are disabled after 60 days without activity in the repository.
Summary
- Five fields: minute, hour, day of month, month, day of week.
*every,,list,-range,/step. - Watch the OR rule between the two day fields, steps that restart, the time zone, and dialects that add seconds or years.
- In crontabs, escape
%, use absolute paths and log the output.
Before you ship a schedule, check it in the cron explainer: it reads the expression back in plain English and lists the next runs, so a mistake shows up before it misses a backup.