← ALL BLOG POSTS

Cron Expressions, Explained Once and For All

Five fields, four operators, and one trap that makes jobs fire on the wrong day. Learn to read any cron expression at a glance, build five real schedules, and preview their verified next run times.

by AI Trend WireDaily AI tools, news and tested workflows — the team behind the KRIYANO blog.

A cron expression is a schedule written on one line. It looks like someone fell asleep on the keyboard — */15 9-17 * * 1-5 — but it follows a small, consistent grammar. Learn the five fields, the four operators, and one rule about days that surprises almost everyone, and you can read any expression ever written.

The five fields

Every standard cron expression has five fields, in this order, read left to right from the smallest unit to the largest:

* * * * *
│ │ │ │ └─ day of week (0-7, both 0 and 7 mean Sunday)
│ │ │ └─── month (1-12)
│ │ └───── day of month (1-31)
│ └─────── hour (0-23)
└───────── minute (0-59)
Field Allowed values Names allowed
Minute 0–59 —
Hour 0–23 —
Day of month 1–31 —
Month 1–12 JAN–DEC
Day of week 0–7 SUN–SAT

The daemon checks the line once a minute. When the current time matches every field, it runs your command. That is the whole mechanism — everything else is notation.

The four operators

Four symbols do all the work:

  • * (star) means “every value.” * in the minute field is every minute.
  • , (comma) builds a list. 1,15 in day of month means the 1st and the 15th.
  • - (hyphen) builds a range. 1-5 in day of week means Monday through Friday.
  • / (slash) builds a step. */15 in the minute field means every 15 minutes; 2-10/3 means 2, 5, 8.

Read */15 9-17 * * 1-5 out loud with that vocabulary: “every 15 minutes, during hours 9 through 17, every day of the month, every month, Monday through Friday.” That is a health check that runs during office hours on weekdays — at :00, :15, :30 and :45 of each hour from 9:00 to 17:45. Note the last run of the day is 17:45, not 18:00: steps cover the hour range, they do not extend past it.

Five real schedules, with verified next run times

Here are five schedules you can copy as-is. The next run times were computed from Friday, December 4, 2026, 08:04 ET — the moment this article was published — and verified against a real cron parser. Paste any of them into the Kriyano Cron Expression Generator to get the next runs from right now.

Schedule Expression Next run
Daily database backup, 2:00 AM 0 2 * * * Sat, Dec 5, 2026, 02:00 ET
Weekday standup reminder, 9:00 AM Mon–Fri 0 9 * * 1-5 Fri, Dec 4, 2026, 09:00 ET
Health check every 15 min, 9 AM–6 PM weekdays */15 9-17 * * 1-5 Fri, Dec 4, 2026, 09:00 ET
Monthly report, 1st of the month, 8:00 AM 0 8 1 * * Fri, Jan 1, 2027, 08:00 ET
Last Friday of the month, 6:00 PM 0 18 * * 5 + a date check (see below) Fri, Dec 25, 2026, 18:00 ET

Each one uses only one restricted day field, which is exactly why they behave the way you expect. The moment you restrict both day fields, the rules change — which brings us to the trap.

The trap: day of month vs day of week

This is the single most misunderstood rule in cron, and it has been biting people since the 1980s. When both the day-of-month and day-of-week fields are restricted — neither is a * — standard cron runs the job when either matches, not when both do.

The Vixie cron man page, which most Linux distributions inherit, says it plainly: “If both fields are restricted (i.e., aren’t *), the command will be run when either field matches the current time.”

So this does not mean “Friday the 13th”:

0 0 13 * 5

It means the 13th of every month and every Friday. Roughly five runs a month where you expected one — and if that job sends an invoice or a report, you find out from your users.

The fix is to restrict one field and check the other inside the command. “First Monday of the month” works the same way: schedule it for every Monday and let the job exit unless the date is on or before the 7th.

Last Friday of the month, done right

The tempting shortcut is wrong for exactly this reason:

0 18 25-31 * 5   # WRONG: runs every Friday AND every day from the 25th to the 31st

The correct version schedules every Friday and guards the command:

0 18 * * 5 [ "$(date +\%d)" -gt 24 ] && /usr/local/bin/monthly-report.sh

The job fires every Friday at 6:00 PM, but the report only runs when the day of the month is past the 24th — and the only Friday that can fall on the 25th through the 31st is the last one. December 2026’s Fridays are the 4th, 11th, 18th and 25th, so only December 25 passes the test: the verified next run is Friday, December 25, 2026, at 18:00 ET.

Two details worth keeping: in a crontab, % is special — it means newline — so every % in a date format must be escaped as \%. And the guard has to live in the command, because cron itself cannot express “last Friday.”

A subtler twist: */2 is not “restricted”

Vixie cron decides whether a field is restricted by checking whether it starts with *. A step value like */2 starts with *, so it counts as unrestricted — and the logic flips back to AND:

0 9 */2 * 1    # AND: odd-numbered days of the month that are also Mondays
0 9 1-31/2 * 1 # OR: every odd-numbered day, PLUS every Monday

Same days in spirit, opposite behaviour in practice. If an expression has a step in a day field, read it twice.

Three more gotchas

Steps restart at the top of each hour. */7 * * * * fires at :00, :07, :14, :21, :28, :35, :42, :49 and :56 — then :00 again. The last gap is 4 minutes, not 7. Steps are anchored to the start of the range, never to the previous run.

Day 31 silently skips five months. 0 0 31 * * never runs in February, April, June, September or November, and 0 0 30 2 * — February 30th — never runs at all. Standard cron has no “last day of the month” token; if the job must run monthly, use the 1st, or use a scheduler that supports one.

* * * * * means 60 runs an hour. A star in the minute field is not “once in a while” — it is every minute. It is the most common cause of a job that “runs way too often,” and it usually appears because someone copied an example and only changed the hour.

Timezones: the question nobody asks until production

System cron runs in the machine’s local time. A server set to UTC runs 0 2 * * * at 2:00 AM UTC; the same line on a laptop in New York runs at 2:00 AM Eastern. That is the entire difference between “the backup ran at 2 AM” and “the backup ran at 9 PM yesterday” — it depends on which clock you mean.

Two consequences follow. First, daylight saving time: a 2:30 AM job is skipped outright on the spring-forward day, because 2:30 AM never happens; a 1:30 AM job can run twice on the fall-back day, because 1:30 AM happens twice. Keep daily jobs out of 1:00–3:00 AM local time, or schedule in UTC. Second, if you are debugging a missed run, convert between epoch and human time carefully — the Kriyano Timestamp Converter does that in one paste, and the difference between seconds and milliseconds is the off-by-1000 bug that eats an afternoon.

Hosted schedulers usually remove the ambiguity by picking UTC for you. GitHub Actions is the one most developers meet first: its schedule trigger takes a five-field POSIX expression, evaluates it in UTC unless you set the optional timezone: key, runs no more often than every five minutes, only reads the workflow file from the default branch, and does not accept the @daily shortcuts or a seconds field. A workflow that “never runs” is almost always a UTC-vs-local mix-up or a file that is not on the default branch.

Other dialects: same idea, different fields

Cron is a family, not a single syntax, and expressions do not port blindly:

Scheduler Fields Notes
Unix / Vixie cron 5: min hour dom mon dow The baseline. 0 and 7 are both Sunday.
GitHub Actions 5, POSIX-style UTC by default; 5-minute minimum; no @ shortcuts.
Quartz (Java) 6–7: sec min hour dom mon dow [year] Seconds first. ? means “no specific value” and is required in one of the two day fields. Supports L (last), W (nearest weekday) and # (nth weekday, so 6#3 is the third Friday).
AWS EventBridge 6: min hour dom mon dow year Also uses ? in one day field.

The ? token is the giveaway that you are looking at Quartz or EventBridge, not Unix cron — and L and W do not exist in classic cron at all. When a schedule behaves strangely after a copy-paste, check which dialect you pasted it into before doubting the expression.

The @ shortcuts are a Vixie convenience, not part of the five-field grammar: @daily is 0 0 * * *, @weekly is 0 0 * * 0, @monthly is 0 0 1 * *, @hourly is 0 * * * *, and @reboot runs once at startup. Handy in a crontab; rejected by GitHub Actions.

How to test before you trust it

  1. Read it back in English. Paste the expression into the Kriyano Cron Expression Generator (or crontab.guru) and check the plain-English description and the next ten run times against what you actually want.
  2. Check the two day fields first. If both are restricted, you have the OR trap — re-read the section above.
  3. Confirm the timezone. On a server, date tells you what the machine thinks the time is. In GitHub Actions, remember it is UTC unless you set a timezone.
  4. Watch the first run. Check the logs (journalctl -u cron or your scheduler’s run history) and confirm the job ran once, at the right minute — not twice, not at all.

If the job rotates credentials or tokens on its schedule, it is worth knowing what it is rotating: our guide to decoding a JWT safely covers how to inspect a token without leaking it.

Cheat sheet

Expression Meaning
* * * * * Every minute
*/5 * * * * Every 5 minutes
0 * * * * Every hour, on the hour
0 0 * * * Every day at midnight
0 9 * * 1-5 Weekdays at 9:00 AM
0 0 * * 0 Every Sunday at midnight
0 0 1 * * 1st of the month at midnight
0 0 1 1 * January 1st at midnight
30 2 * * * Every day at 2:30 AM
15 5,17 * * * Every day at 5:15 AM and 5:15 PM

Five fields, four operators, one trap. Everything else is just choosing the numbers.

cronautomationdeveloper-tools