Cron Expressions Explained: Schedule Any Task with Confidence
Cron syntax looks cryptic at first. This guide breaks down all five fields, special characters, and real-world scheduling patterns — from every-minute jobs to complex monthly runs.
What Is a Cron Job?
Cron is a time-based job scheduler in Unix/Linux systems. A cron job is a command or script that runs automatically at a defined schedule. It is the go-to solution for tasks like database backups, sending digest emails, cleaning up temp files, or fetching data from external APIs.
The schedule is defined using a compact string called a cron expression. Once you understand the five fields, you can express almost any repeating schedule in under 15 characters.
The Five Fields
┌──────────── minute (0–59) │ ┌─────────── hour (0–23) │ │ ┌──────── day of month (1–31) │ │ │ ┌───── month (1–12 or JAN–DEC) │ │ │ │ ┌── day of week (0–7 or SUN–SAT) │ │ │ │ │ * * * * *
| Position | Field | Allowed values | Example |
|---|---|---|---|
| 1st | Minute | 0–59 | 30 |
| 2nd | Hour | 0–23 | 14 |
| 3rd | Day of month | 1–31 | 15 |
| 4th | Month | 1–12 or JAN–DEC | 6 |
| 5th | Day of week | 0–7 or SUN–SAT (0=7=Sun) | MON |
Special Characters
| Character | Meaning |
|---|---|
| * | Any value — match all |
| , | List separator — e.g. MON,WED,FRI |
| - | Range — e.g. 9-17 means 9 through 17 |
| / | Step — e.g. */15 means every 15 units |
| @yearly | Shorthand for 0 0 1 1 * |
| @monthly | Shorthand for 0 0 1 * * |
| @weekly | Shorthand for 0 0 * * 0 |
| @daily | Shorthand for 0 0 * * * |
| @hourly | Shorthand for 0 * * * * |
12 Real-World Cron Patterns
| Expression | Runs |
|---|---|
| * * * * * | Every minute |
| 0 * * * * | Every hour, at minute 0 |
| 0 0 * * * | Every day at midnight |
| 0 9 * * MON-FRI | Weekdays at 9:00 AM |
| 0 9 * * 1 | Every Monday at 9:00 AM |
| */15 * * * * | Every 15 minutes |
| 0 0 1 * * | First day of every month at midnight |
| 0 0 1 1 * | Once a year, January 1st at midnight |
| 30 23 * * FRI | Every Friday at 11:30 PM |
| 0 6,18 * * * | Twice a day: 6 AM and 6 PM |
| 0 9-17 * * MON-FRI | Every hour during business hours on weekdays |
| 5 4 * * SUN | Every Sunday at 4:05 AM (common backup window) |
How to Read Any Cron Expression
Use this mental model — read the fields right to left, from largest to smallest unit:
Expression: 30 8 * * MON-FRI
→ Weekdays (MON–FRI), every month, every day-of-month, at 8 AM, at minute 30
→ Every weekday at 08:30
When two fields conflict — e.g. day-of-month = 15 and day-of-week = MON — most cron implementations trigger if either condition is true (OR logic), not both. Check your scheduler's documentation if you rely on both fields simultaneously.
Common Cron Gotchas
- Timezone is the server timezone — if your server runs UTC,
0 9 * * *fires at 9 AM UTC, not your local time. - No seconds field in standard cron — if you need sub-minute scheduling, use your application's built-in scheduler (e.g. node-cron, APScheduler) which often adds a 6th field for seconds.
- Day 0 and day 7 both mean Sunday — both are valid in most implementations.
- Missed jobs do not queue up — if the server is down when a job was scheduled, cron does not run it when the server comes back online.
- Long-running jobs can overlap — add a lock mechanism if your job might still be running when the next execution starts.
Build cron expressions visually
Use the StackUtils Cron Builder to create and validate expressions with an interactive UI — no syntax memorisation required.
Open Cron Builder →