CronHub

Build cron expressions visually — with a live schedule preview.

Cron Syntax Explained: The 5 Fields Made Easy

Cron syntax is a five-field time format that tells Linux exactly when to run a command. Once you can read those five fields, every cron expression becomes obvious. Here is the layout you will use every time:

* * * * *  command to run
│ │ │ │ │
│ │ │ │ └─ Day of week   (0–7, Sun=0 or 7)
│ │ │ └─── Month         (1–12)
│ │ └───── Day of month  (1–31)
│ └─────── Hour          (0–23)
└───────── Minute        (0–59)

Read left to right: minute, hour, day of month, month, day of week, then the command. Master this and the rest is detail. Let's break down each part of the crontab syntax with correct, copy-ready examples.

The Five Cron Fields

Each of the five positions accepts a number in a fixed range. An asterisk (*) means "every value" for that field.

FieldAllowed valuesMeaning
Minute0–59Minute of the hour
Hour0–23Hour in 24-hour time
Day of month1–31Calendar day
Month1–12 (or Jan–Dec)Month of year
Day of week0–7 (or Sun–Sat)Weekday

A simple example — run a script at 6:00 a.m. every day:

0 6 * * * /home/sam/morning.sh

Minute 0, hour 6, any day, any month, any weekday. That is the entire cron time format in one line.

Cron Special Characters

The real power of cron syntax comes from a handful of special characters that combine values.

Asterisk (*) — every value

Matches all values in the field.

* * * * * /path/task.sh   # every minute

Comma (,) — a list of values

Run at several specific times.

0 8,12,18 * * * /path/task.sh   # 8am, 12pm, 6pm

Hyphen (-) — a range

Run across a continuous span.

0 9-17 * * 1-5 /path/task.sh   # top of every hour, 9am–5pm, Mon–Fri

Slash (/) — step values

Run at regular intervals within a range.

*/15 * * * * /path/task.sh    # every 15 minutes
0 */2 * * * /path/task.sh     # every 2 hours

*/15 in the minute field means "starting at 0, every 15 minutes" — so 0, 15, 30, 45. Steps can also apply to a range: 0-30/10 means 0, 10, 20, 30, and 5-30/5 means minutes 5, 10, 15, 20, 25, 30.

Named Values and Shortcuts

Cron accepts three-letter names for months and weekdays, which many people find easier to read:

0 0 * * MON /path/weekly.sh   # every Monday at midnight
0 0 1 JAN * /path/newyear.sh  # January 1st at midnight

There are also special string shortcuts that replace all five fields:

ShortcutEquivalentMeaning
@rebootOnce at startup
@yearly / @annually0 0 1 1 *Once a year
@monthly0 0 1 * *First of the month
@weekly0 0 * * 0Every Sunday
@daily / @midnight0 0 * * *Every day at midnight
@hourly0 * * * *Top of every hour

Example:

@daily /home/sam/backup.sh

A Note on Six-Field Variants

Not every "cron expression" has exactly five fields, and knowing the variants saves confusion:

When a tool asks for "cron syntax," check which dialect it means before copying an expression across.

Common Cron Syntax Mistakes

These gotchas catch nearly everyone at least once.

Reading a Cron Expression Step by Step

Let's decode one:

30 3 1,15 * * /opt/reports/generate.sh

Result: run at 3:30 a.m. on the 1st and 15th of every month. Working through the fields in order makes any cron expression readable.

Best Practices for Writing Cron Syntax

Conclusion

Cron syntax is just five time fields plus a command, sharpened by a few special characters: * for every, , for lists, - for ranges, and / for steps. Learn those and you can schedule almost anything. Watch out for the Sunday and day-of-month gotchas, always use absolute paths, and validate expressions before saving.

Ready to put this into practice? Grab ready-to-use jobs from our crontab examples library, or follow our step-by-step guide to set up your first cron job on Linux.

Frequently Asked Questions

What does * * * * * mean in cron?

It means "run every minute of every hour, every day." All five fields are wildcards, so the command executes once per minute continuously.

How do I run a cron job every 15 minutes?

Use a step value in the minute field: */15 * * * *. This runs the command at minutes 0, 15, 30, and 45 of every hour.

What is the difference between day of month and day of week in cron?

They are the third and fifth fields. If you set both to specific values, cron runs when either matches (an OR), not only when both match — a frequent source of confusion.

Are the days of the week 0-based in cron?

Yes. Sunday is 0, Monday is 1, up to Saturday which is 6. As a special case, 7 also means Sunday, so both 0 and 7 are valid.

Need the expression itself? Build and test any cron schedule in our free visual generator — with live upcoming-run previews in Unix and Quartz formats.

Related guides

References