ToolPiq.
Guides / Dev

Cron expressions explained: schedule anything with 5 fields

Cron is how servers everywhere run tasks on a schedule — backups at 2 a.m., a report every Monday, a cleanup every 15 minutes. The syntax looks cryptic but it's just five fields.

The five fields

A cron expression is five values separated by spaces, each answering "when":

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

An asterisk * means "every." So * * * * * means every minute of every hour of every day.

The special characters

  • * — every value.
  • , — a list: 1,15,30 means at 1, 15, and 30.
  • - — a range: 9-17 means 9 through 17.
  • / — a step: */15 in the minute field means "every 15 minutes."

Copy-ready examples

  • 0 2 * * * — every day at 2:00 a.m.
  • */15 * * * * — every 15 minutes.
  • 0 9 * * 1 — every Monday at 9:00 a.m.
  • 0 0 1 * * — midnight on the first of every month.
  • 0 9-17 * * 1-5 — every hour, 9 a.m.–5 p.m., Monday to Friday.

The gotcha to watch

Both "day of month" and "day of week" exist, and mixing them confuses people. If you set both to specific values, most cron implementations run when either matches, not both. When in doubt, leave one as *. The safest way to get a schedule right is to build the expression and read its plain-English meaning back before you deploy it.

Build a cron expression →


← All guides · Browse all tools →