Skip to content
DevOpscroncrontabcron expression syntaxcron every 5 minutesschedulingautomation

Cron Expression Syntax Explained: A Field-by-Field Guide

Cron expression syntax explained field by field — asterisks, ranges, step values like */5, macros like @daily, and the mistakes that break schedules.

Diagram of cron expression syntax showing the five fields minute hour day of month month and day of week with the */5 step value highlighted
The five fields of a cron expression — */5 means every 5 minutes
SyntaxFiddle Editorial4 min read
On this page

Cron expression syntax is terse by design: five fields decide when backups run, certificates renew, and log files rotate. Because that syntax is so compact, it is also one of the most common sources of production incidents. This guide explains every field — and the asterisks, ranges, step values, and shortcut macros like @daily that answer the questions people actually search for, such as how do I run a job every 5 minutes?

What the five cron fields mean

A classic Unix crontab entry has five fields followed by the command to run:

bash
# ┌───────────── minute        (0–59)
# │ ┌───────────── hour        (0–23)
# │ │ ┌───────────── day of month (1–31)
# │ │ │ ┌───────────── month   (1–12)
# │ │ │ │ ┌───────────── day of week (0–7, 0 and 7 are Sunday)
# │ │ │ │ │
# * * * * *  /usr/local/bin/backup.sh

That first example — 0 2 * * * — reads "at minute 0 of hour 2, every day": a 2 AM nightly job. Reading a five-field expression out loud is the fastest way to sanity-check it.

FieldAllowed valuesMeaning
Minute0–59Minute of the hour
Hour0–23Hour of the day (server local time)
Day of month1–31Calendar day
Month1–12Calendar month
Day of week0–70 and 7 are both Sunday

Cron special characters: asterisk, comma, hyphen, slash

Four characters do all the heavy lifting inside those fields:

The asterisk — every value

bash
* * * * * /opt/healthcheck.sh

An asterisk means "match everything", so this runs the healthcheck once a minute.

The comma — value lists

bash
0 6,12,18 * * * /opt/sync.sh

Runs at 6:00, 12:00, and 18:00 every day. Lists are great for business-hours schedules.

The hyphen — ranges

bash
0 9-17 * * 1-5 /opt/report.sh

Top of every hour from 9 AM to 5 PM, Monday through Friday — the classic business-hours job.

The slash — step values (every N minutes)

The step modifier answers the most-searched cron question: how to run a job every 5 minutes.

bash
*/10 * * * * /opt/poll.sh

Every tenth minute: 0, 10, 20, 30, 40, 50. Steps can start anywhere — 15/10 means 15, 25, 35, 45, 55.

Cron shortcut macros: @daily, @hourly, @reboot

Most modern cron daemons accept named aliases for common schedules:

MacroEquivalent
@yearly0 0 1 1 * — once a year, January 1 at midnight
@monthly0 0 1 * * — first of every month at midnight
@weekly0 0 * * 0 — Sunday at midnight
@daily0 0 * * * — every day at midnight
@hourly0 * * * * — top of every hour
@rebootOnce, immediately after the cron daemon starts

Five pitfalls that break schedules

  1. Timezone drift. Cron evaluates expressions in the daemon's local time. Containers default to UTC — a "2 AM backup" written for an Eastern Time server silently runs at 9 PM Eastern.
  2. Day-of-month plus day-of-week. When both fields are restricted, cron fires on days matching either, not both. 0 0 13 * 5 runs on the 13th and on every Friday.
  3. DST gaps. Jobs scheduled inside a spring-forward window (2:00–3:00 AM in most US zones) simply skip that day.
  4. Percent signs. In a crontab, % is a newline marker. Escape it as \% inside commands or date arguments.
  5. Silent env differences. Cron runs commands with a minimal environment — use absolute paths to binaries and files, and redirect output to a log.

Verify before you deploy

Read the expression aloud, check the server's timezone, and simulate the next few runs before a schedule reaches production. You can paste any expression into the Cron Tester & Generator to see the next execution times, a plain-English explanation of the syntax, and dialect-specific warnings — all computed locally in your browser.

Try it while you read

Cron Tester & Generator — Parse, explain, and simulate cron schedules in plain English.

Open tool

Frequently Asked Questions

What are the five fields in a cron expression?

Minute (0–59), hour (0–23), day of month (1–31), month (1–12), and day of week (0–7, where both 0 and 7 mean Sunday), followed by the command to run. Reading them left to right as minute-through-day-of-week is the fastest way to sanity-check any schedule.

How do I run a cron job every 5 minutes?

Use */5 * * * * — the step modifier /5 applied to the minute range fires at 0, 5, 10, and so on. To offset the start, combine it with a range: 10-59/5 fires at 10, 15, 20, and onward.

What is the difference between */5 and 5 in the minutes field?

*/5 fires every five minutes starting at the top of the hour (0, 5, 10, and so on), while a plain 5 fires once per hour at minute 5. The slash is a step modifier applied to the whole range, not a repeat count.

Why did my cron job stop running after a server reboot?

On most Linux distributions, user crontabs persist across reboots, but @reboot jobs only fire at startup. If the cron daemon itself is not enabled, nothing will run until you start and enable it with systemctl.

← All articles