⚡ SmartDevTools

Cron Expressions Explained

By SmarTech Apps · Published 2026-11-18 · 6 min read

A cron expression is a short string that says when a job should run. The syntax is tiny, which is why people memorise just enough to be dangerous: a schedule that was meant to run once a day runs every minute, or never runs at all because of a time-zone assumption. This guide walks through the format and the places where it surprises people.

The five fields

Classic Unix cron (Vixie cron and its relatives) uses five space-separated fields:

+---------- minute        0-59
| +-------- hour          0-23
| | +------ day of month  1-31
| | | +---- month         1-12 (or JAN-DEC)
| | | | +-- day of week   0-7  (0 and 7 are Sunday; or SUN-SAT)
| | | | |
* * * * *  command

A job fires when the current time matches every field. So 30 2 * * * means minute 30 of hour 2 on any day: 02:30 every day. A field containing * matches everything.

Ranges, lists and steps

Each field accepts a few operators that can be combined:

Steps count from the start of the field's range, not from the moment you installed the job. */7 in the minute field gives 0, 7, 14, 21, 28, 35, 42, 49, 56, and then restarts at 0 in the next hour, so the gap between 56 and 0 is only four minutes. Steps divide evenly only when the step divides the range.

Examples and what they mean

ExpressionMeaning
* * * * *Every minute
*/15 * * * *Every 15 minutes (:00, :15, :30, :45)
0 * * * *At the start of every hour
0 */2 * * *Every two hours at minute 0 (00:00, 02:00 ... 22:00)
0 9 * * 1-509:00 on weekdays, Monday to Friday
30 2 1 * *02:30 on the first day of every month
0 0 * * 0Midnight at the start of Sunday
0 0 1 1 *Midnight on 1 January
0 8,12,18 * * *08:00, 12:00 and 18:00 every day
0 0 13 * 5Midnight on the 13th or on any Friday (see below)

You can type any of these into our Cron Expression Builder. It has five boxes (minute, hour, day of month, month, day of week) plus the full expression field, the two stay in sync, and below them it prints a short description and the next ten run times in your browser's local time. Its description is deliberately terse (for instance, "minute 0, hour 9, day Monday to Friday"), so use the next-run list as the real check of what a schedule does. It accepts five fields only; a six-field Quartz string will show a warning.

Day of month and day of week: an OR, not an AND

This is the most misunderstood rule. When both the day-of-month and day-of-week fields are restricted (neither is *), standard cron runs the job when either matches. Many people write 0 0 13 * 5 expecting "Friday the 13th". It actually fires on every 13th and every Friday. If you want a true AND, schedule on the more frequent day and test the other condition inside the job, for example run every Friday and exit unless date +%d is 13.

Special strings and other dialects

Vixie-style cron also accepts shortcuts: @hourly, @daily, @weekly, @monthly, @yearly and @reboot. They are not universal. Schedulers that embed a cron parser may accept only the five numeric fields, or support just some of the shortcuts, and @reboot only makes sense on a machine that boots. Check the documentation of your platform (CI services, Kubernetes CronJobs, cloud schedulers) before relying on them.

Six and seven fields: Quartz and Spring

Java's Quartz scheduler and Spring's @Scheduled use a leading seconds field: second, minute, hour, day of month, month, day of week (Quartz also allows an optional trailing year). Because AND-ing the two day fields is not allowed there, Quartz requires a ? ("no specific value") in one of them:

0 0 12 ? * MON-FRI     # 12:00:00 every weekday (Quartz)
0 15 10 * * ?          # 10:15:00 every day
0 0/5 * * * *          # every 5 minutes, on second 0 (Spring)

Shifting every field by one is the usual migration bug: pasting a five-field expression into Spring makes it fail to parse, and pasting a six-field one into a crontab is rejected or misread. Day-of-week numbering also differs between dialects (in Quartz 1 is Sunday), so names such as MON-FRI are safer than digits.

Time zones and daylight saving

Cron has no time-zone syntax. It uses whatever the scheduler's zone is: the server's local time for a system crontab, UTC for many cloud and CI schedulers, and a configurable zone in others. "Every day at 09:00" is only meaningful once you know which one. Servers should generally run in UTC, with local conversion done by humans. Our Timezone Converter helps you work out the UTC equivalent of a local business hour, and Unix Timestamps and Time Zones explains why UTC is the safe internal choice.

If the scheduler uses a zone with daylight saving time, local times can vanish or repeat. A job at 02:30 may be skipped on the night the clocks jump forward, since 02:30 does not exist, and some implementations run a job twice when the clocks go back. Behaviour varies by implementation, so avoid scheduling important jobs in the 01:00 to 03:00 window of a DST zone, or schedule in UTC.

Common mistakes

Last, if a job triggers other systems, make the schedule the dull part: log each start, check exit codes and alert on silence, not only on errors. If you are scheduling health checks that report HTTP failures, see HTTP Status Codes Explained for what to alert on. When a string such as a log line needs parsing in the same pipeline, our Regex Tester is handy; the pitfalls are in Regex Patterns and Pitfalls.

Try the tools

Keep reading