What is a cron job?
A cron job is a scheduled command that runs at fixed times or intervals on Unix-like systems. The schedule is one line — five space-separated fields called a cron expression — telling the cron daemon when to fire. Linux, macOS, Kubernetes, GitHub Actions and AWS use the same syntax.
Anatomy of a cron job
A crontab entry has two halves — the schedule (when) and the command (what):
*/5 * * * * /usr/local/bin/backup.sh
└────┬────┘ └─────────┬─────────────┘
Schedule Command
The schedule itself is five fields, in this order:
| Field | Range | Example |
|---|---|---|
| Minute | 0–59 | */5 = every 5 minutes |
| Hour | 0–23 | 9 = 9 AM |
| Day of month | 1–31 | 1 = first of month |
| Month | 1–12 | * = every month |
| Day of week | 0–6 (Sun=0) | 1-5 = Mon–Fri |
* means “any value”, */N means “every N units”, and a comma separates a list (1,15 matches the 1st and 15th). That covers most cron expressions you’ll meet.
How do I read a cron expression?
Translate field-by-field, left to right:
0 9 * * 1→ minute 0, hour 9, any day-of-month, any month, day-of-week 1 → Mondays at 9:00.0 0 1 * *→ minute 0, hour 0, day 1 of the month, any month, any day-of-week → midnight on the 1st of every month.*/15 * * * *→ every 15 minutes, every hour, every day → every quarter hour, around the clock.0 2 * * 0→ minute 0, hour 2, any day-of-month, any month, Sunday → Sundays at 2 AM.
If you can’t decode an expression at a glance, paste it into the Cron Expression Builder — it shows the human-readable description and the next 5 fire times.
What kinds of work do cron jobs do?
Anything that needs to run on a schedule rather than in response to user actions:
| Use case | When | Cron expression |
|---|---|---|
| Hourly log rotation | every hour, on the hour | 0 * * * * |
| Daily database backup | every day at 2 AM | 0 2 * * * |
| Weekly analytics report | Mondays at 9 AM | 0 9 * * 1 |
| Monthly invoice run | midnight on the 1st | 0 0 1 * * |
| Health-check ping | every 5 minutes | */5 * * * * |
| Cache warm-up before traffic peak | weekdays at 8:55 AM | 55 8 * * 1-5 |
Where do cron jobs actually run?
The same 5-field syntax shows up everywhere — once you learn it, it transfers across platforms:
- Linux & macOS — the
cron(orcrond) daemon reads/var/spool/cron/crontabs/<user>, plus/etc/crontaband/etc/cron.d/for system jobs. Edit your user crontab withcrontab -e. - Kubernetes —
CronJobresources schedule pods. Same syntax in theschedule:field, butconcurrencyPolicy(Allow / Forbid / Replace) determines what happens when a previous run is still going. The Kubernetes CronJob schedule generator walks through the full manifest with timezone, concurrency and starting-deadline fields. - GitHub Actions —
on: schedule:with acron:key. UTC always, with a 5-minute minimum granularity enforced by the runner. - AWS EventBridge / Scheduler — wrapped in
cron(...)with a sixth year field and?for one of day-of-month or day-of-week. See the AWS EventBridge guide for the full ruleset. - Most CI runners (GitLab, Jenkins, CircleCI) — each adds small dialect tweaks but builds on the same 5-field core.
Common mistakes when writing cron jobs
Commands don’t pick up your interactive shell. Cron runs commands with a minimal PATH and no ~/.bashrc, ~/.zshrc or login profile. Either use absolute paths (/usr/local/bin/python3 /opt/scripts/run.py) or set PATH= at the top of the crontab. The number-one reason a cron job “works on my terminal but not in cron” is environment.
Output goes to email by default — and email usually goes nowhere. Standard cron mails any stdout/stderr to the local mailbox. On modern systems with no mailer configured, the output is silently dropped. Always redirect: >> /var/log/myjob.log 2>&1.
Day-of-month and day-of-week interact weirdly. When both are specified (0 9 15 * 1) Unix cron treats it as OR — runs on the 15th of the month and every Monday, not the intersection. To get “Mondays at 9 AM”, leave day-of-month as *. AWS EventBridge sidesteps this by requiring ? for one of the two fields.
For ready-to-paste expressions covering specific intervals, see common cron schedules, or build a custom expression with the Cron Expression Builder.
Frequently asked questions
- What is the difference between a cron job and a cron expression?
- A **cron expression** is just the schedule — five space-separated fields like `*/5 * * * *`. A **cron job** is the full entry: the expression plus the command to run plus (on Unix) the user identity it runs as. The expression tells cron *when*; the job is *when + what*.
- Do cron jobs run if my computer is asleep or off?
- No — classic cron is a daemon that needs the machine running at the scheduled time. macOS uses launchd which can wake the system for some jobs; Linux uses anacron to "catch up" missed jobs after wake. Cloud schedulers like AWS EventBridge and Kubernetes CronJobs are independent of any single machine being on, which is why they're preferred for production schedules.
- How do I create my first cron job on Linux?
- Run `crontab -e` to open your user crontab in `$EDITOR`, add a line in the form `<schedule> <command>` (e.g. `0 9 * * 1 /usr/local/bin/weekly-report.sh`), save and exit. Verify with `crontab -l`. Output goes to mail by default — redirect with `>> /var/log/myjob.log 2>&1` to capture it.
Need a different schedule?
Build cron expressions for Unix, Kubernetes, AWS EventBridge and Quartz — with a human-readable description and the next 5 run times.
Open the Cron Expression Builder →Related
Cron expression for every 5 minutes
The cron expression `*/5 * * * *` runs every 5 minutes in Linux crontab, Kubernetes, GitHub Actions; `cron(*/5 * * * ? *)` in AWS EventBridge.
Cron expression for every 15 minutes
The cron expression `*/15 * * * *` runs every 15 minutes — at :00, :15, :30, :45 — across Linux, Kubernetes, GitHub Actions and AWS.
Cron expression for every 30 minutes
The cron expression `*/30 * * * *` runs every 30 minutes — at :00 and :30 of every hour. Same in Linux, Kubernetes and GitHub Actions; `cron(*/30 * * * ? *)` in AWS.
Cron expression for every hour
The cron expression `0 * * * *` runs once per hour on the hour. Same syntax in Linux, Kubernetes and GitHub Actions; `cron(0 * * * ? *)` in AWS EventBridge.
Cron expression for daily at midnight
The cron expression `0 0 * * *` runs once daily at midnight. Watch the timezone — Kubernetes < 1.25 and AWS EventBridge default to UTC, not local time.
Cron expression for every weekday
The cron expression `0 9 * * 1-5` runs at 9 AM Monday through Friday. AWS uses `cron(0 9 ? * MON-FRI *)` because day-of-week numbering differs.