← Guides

Cron Expression Explained: Syntax, Characters & Examples

What a cron expression is

A cron expression is a compact string that tells a scheduler “run this command at these times.” You’ll meet it in cron (Linux), CI pipelines, Kubernetes CronJobs, and most cloud schedulers.

The five fields

Most expressions have five space-separated fields:

┌─ minute (0–59)
│ ┌─ hour (0–23)
│ │ ┌─ day of month (1–31)
│ │ │ ┌─ month (1–12)
│ │ │ │ ┌─ day of week (0–6, Sunday=0)
│ │ │ │ │
* * * * *

Special characters

  • * — “every” value. 30 2 * * * = 2:30 every day.
  • , — list. 0 9,17 * * * = 9:00 and 17:00.
  • - — range. 0 9-17 * * * = every hour from 9 through 17.
  • / — step. */15 * * * * = every 15 minutes.
  • ? — “no specific value” (used in day-of-month / day-of-week to avoid a conflict).

Common examples

  • 0 0 * * * — midnight every day
  • 0 0 * * 0 — midnight every Sunday
  • */10 * * * * — every 10 minutes
  • 0 8 1 * * — 08:00 on the 1st of every month

Where cron expressions actually run

On Linux and macOS the cron daemon reads a crontab entry, wakes once a minute and runs any job whose fields match the current clock. The same syntax has been copied by CI pipelines, Kubernetes CronJobs, GitHub Actions schedules, AWS EventBridge and a long list of application schedulers. The fields look identical across those systems, but the surrounding rules do not always agree, so an expression that behaves perfectly on one platform can fire at surprising times on another.

Field reference

FieldAllowed valuesWhat it controls
Minute0–59Minute of the hour
Hour0–23Hour of the day, 24-hour clock
Day of month1–31Calendar day; months have different lengths
Month1–12January is 1; some dialects also accept JAN
Day of week0–6Sunday is 0 in classic cron; 1 is Monday

Out-of-range values are not always rejected. Some schedulers clamp them, others refuse to load the file at all, so a value such as 60 in the minute field may fail silently or loudly.

Day of month and day of week are combined with OR

This is the most misunderstood rule in cron. When both day fields contain a value, classic cron runs the job if either one matches, not both. 0 0 13 * 5 therefore means “midnight on the 13th and also every Friday,” not “midnight on Friday the 13th.” To express a job that runs only when both conditions hold, split it into two expressions or add a date check inside the command. Quartz solves the problem by requiring ? in one of the two fields, which is why expressions copied from Quartz often look unfamiliar. A star in one field plus a value in the other behaves as most people expect: the star matches everything, so the single constraint decides.

Time zones, UTC and daylight saving time

Cron compares against the clock of the machine or container running the scheduler, not the clock of the person who wrote the expression. A server set to UTC will fire a job written for “2:30” at a completely different local hour, and a container usually defaults to UTC even when the developer’s laptop is not. Daylight saving time adds two sharper edges: in spring the clock jumps from 02:00 to 03:00, so a job scheduled inside that skipped hour never runs that day; in autumn the clock repeats an hour, so a job scheduled inside it can run twice.

Overlapping runs and missed runs

Cron starts jobs on time but does nothing about what happens after. If a job takes longer than its interval, the next run starts while the previous one is still working, and two copies then race over the same files or database rows. The usual defence is a lock: flock on Linux, a unique index or a job-status row in the database, or a scheduler-level setting that forbids concurrent runs. The opposite problem is just as common: if the machine is down at the scheduled moment, cron does not replay the missed run unless a tool such as anacron or a cloud scheduler’s retry policy is configured. Long-running maintenance jobs should therefore log their start and finish, and alert when a run is missing rather than only when a run fails.

Mistakes that cost the most time

  • Five fields written for a six-field scheduler — the whole expression shifts one field to the right and the job fires at the wrong hour.
  • Expecting seconds — classic cron cannot run more often than once a minute; */30 * * * * * is not “every 30 seconds.”
  • Ignoring the server time zone — a report that runs at 08:00 UTC arrives at 16:00 in Shanghai, not 08:00.
  • Assuming the user environment — cron starts with a minimal PATH and no shell profile, so a command that works in a terminal can fail with “command not found” because a runtime or a virtual environment is simply not on the path.
  • No logging — output is often mailed or discarded; redirect stdout and stderr to a file so a silent failure leaves evidence.

Cron compared with other schedulers

OptionBest forWatch out for
System cronSimple recurring jobs on one hostLocal time zone, no retries, minimal environment
systemd timersJobs that need logging, dependencies or catch-up runsDifferent configuration model and OnCalendar syntax
Kubernetes CronJobContainerised batch work in a clusterEvaluated in UTC by default; pods overlap if not restricted
Cloud schedulerJobs tied to a managed platformVendor-specific field count and time zone settings

A checklist before you deploy

  • Confirm the field count expected by the target scheduler.
  • Decide and document the time zone; prefer UTC for anything financial or daily.
  • Check what happens during a daylight saving transition.
  • Verify the command with the same environment, user and working directory cron will use.
  • Add a lock or concurrency guard for jobs that can run longer than their interval.
  • Redirect output to a log and alert on missing runs, not only on errors.

For a related read on storing and comparing time values, see our guide on Unix timestamps: seconds vs milliseconds.

Not sure what an expression means? Paste it into our Cron Expression Tool to get a plain-English description and the next run times.

Try it yourself: open the Cron Expression Tool →