Cron is the scheduler that runs jobs at fixed times on Unix-like systems and powers the schedule syntax in countless CI pipelines, cloud functions, and container platforms. A cron expression is the compact string that says when. Once you learn its five fields and a few special characters, you can read any schedule at a glance. This guide is a practical reference with copy-ready examples.
What do the five cron fields mean?
A standard cron expression is five space-separated fields, read left to right:
┌───────── minute (0-59)
│ ┌─────── hour (0-23)
│ │ ┌───── day of month (1-31)
│ │ │ ┌─── month (1-12)
│ │ │ │ ┌─ day of week (0-6, Sun=0)
│ │ │ │ │
* * * * *
A field matches when the current time value falls in it. The job runs only when all five fields match at the same minute (with one important exception for the two “day” fields, covered below).
| Field | Allowed values | Notes |
|---|---|---|
| Minute | 0–59 | |
| Hour | 0–23 | 24-hour clock |
| Day of month | 1–31 | |
| Month | 1–12 | or JAN–DEC |
| Day of week | 0–6 | 0 and 7 = Sunday; or SUN–SAT |
What do the special characters mean?
Four characters do almost all the work:
| Symbol | Name | Meaning | Example |
|---|---|---|---|
* | Wildcard | Every value in the field | * * * * * = every minute |
, | List | Several specific values | 0,30 = at :00 and :30 |
- | Range | A contiguous span | 9-17 = 9 through 17 |
/ | Step | Every nth value | */15 = every 15 units |
Steps combine with ranges and wildcards: 0-30/10 in the minute field means minutes 0, 10, 20, 30.
Ready-to-copy cron examples
| Expression | Runs |
|---|---|
* * * * * | Every minute |
*/5 * * * * | Every 5 minutes |
0 * * * * | Every hour, on the hour |
0 9 * * * | Every day at 09:00 |
30 8 * * 1-5 | 08:30, Monday–Friday |
0 0 * * 0 | Midnight every Sunday |
0 0 1 * * | Midnight on the 1st of each month |
0 0 1 1 * | Midnight on 1 January (yearly) |
*/10 9-17 * * 1-5 | Every 10 min, 9am–5pm, weekdays |
15 2 * * 6 | 02:15 every Saturday |
What is the day-of-month vs. day-of-week trap?
This is the single most common cron bug. When both the day-of-month (field 3) and day-of-week (field 5) are restricted (neither is *), the traditional Vixie cron behaviour is an OR, not an AND. The job runs when either field matches.
So 0 0 1 * 1 does not mean “midnight on a Monday that is also the 1st.” It means “midnight on the 1st of the month and midnight every Monday.” If you truly need “the 1st and a Monday,” you cannot express it in one standard cron line — you typically add a guard in the job itself (check the date and exit early).
The safe rule: keep at least one of the two day fields as * unless you understand the OR semantics.
Timezones, seconds, and dialects
Cron syntax is not perfectly universal — watch for these differences:
- Timezone. Classic Unix cron uses the server’s local time; many cloud schedulers default to UTC. Schedules around 02:00 can fire twice or be skipped during daylight-saving transitions. If you are converting a wall-clock time to UTC, our Unix timestamp converter helps you reason about the offset.
- Seconds field. Some systems (Quartz, certain cloud crons) add a leading seconds field, making it six fields. Standard Unix cron has no seconds field — the finest resolution is one minute.
- Day-of-week numbering. Most crons treat
0=Sunday, but some allow7=Sunday too, and a few platforms differ. Confirm before relying on it. - Special strings. Many crons accept shortcuts like
@hourly,@daily,@weekly,@monthly, and@rebootin place of an expression.
A workflow for writing a cron schedule
- Write the time in words first — “every weekday at 8:30am.”
- Fill the fields right to left: day-of-week (
1-5), month (*), day-of-month (*), hour (8), minute (30) →30 8 * * 1-5. - Avoid the day trap: keep one day field as
*. - Confirm the timezone your scheduler uses.
- Test the next few run times before deploying.
Cron schedules often coordinate jobs that generate IDs and timestamps — if your pipeline stamps records, see UUID v4 vs v7 for time-ordered identifiers, and the Unix timestamp converter for translating epoch values your jobs emit.
Sources
- crontab(5) manual page (Vixie cron field definitions and day-OR behaviour).
- POSIX, crontab utility specification.
- Cloud provider scheduler documentation for timezone and seconds-field variations.