Dev Utilities·7 min read·By the developer of StackUtils

Cron Expressions Explained: Schedule Any Task with Confidence

Cron syntax looks cryptic at first. This guide breaks down all five fields, special characters, and real-world scheduling patterns — from every-minute jobs to complex monthly runs.

What a cron expression actually describes

Cron is the Unix job scheduler. Each line of a crontab pairs a schedule with a command, and the schedule is a cron expression: five space-separated fields that describe which minutes a job is allowed to run in. Once a minute, the cron daemon wakes up, checks every line against the current local time, and starts the commands whose fields all match.

That "checked once a minute" model explains most of cron's behaviour: there is no queue, no catch-up and no memory of previous runs. The same five-field syntax is reused by Kubernetes CronJobs, GitHub Actions schedule triggers, and libraries such as node-cron, but each of them adds its own rules, which is where most scheduling bugs come from.

The five fields

┌──────────── minute        (0–59)
│ ┌────────── hour          (0–23)
│ │ ┌──────── day of month  (1–31)
│ │ │ ┌────── month         (1–12 or JAN–DEC)
│ │ │ │ ┌──── day of week   (0–7 or SUN–SAT; 0 and 7 are both Sunday)
│ │ │ │ │
30 8 * * 1-5   /usr/local/bin/send-report.sh

Inside each field you can use four operators:

SyntaxMeaningExample
*Every value of the field* in the hour field = every hour
a,b,cA list of values0 6,18 * * * = 06:00 and 18:00
a-bAn inclusive range0 9-17 * * * = every hour from 09:00 to 17:00
*/n or a-b/nEvery n-th value, starting at the range start*/15 = minutes 0, 15, 30, 45

Month and weekday names (JAN, MON) are case-insensitive in Vixie cron and cronie, the implementations shipped by most Linux distributions, but names cannot be used inside ranges on every system. If a crontab has to be portable, numbers are the safer choice.

Worked examples: expression → next runs

The quickest way to check a schedule is to list the next few times it fires. The runs below were computed for a clock starting at Monday 9 November 2026, 12:00, using Vixie cron rules.

30 8 * * 1-5      → Tue 10 Nov 08:30, Wed 11 Nov 08:30, Thu 12 Nov 08:30,
                    Fri 13 Nov 08:30, Mon 16 Nov 08:30   (weekdays only)

*/7 12 * * *      → 12:07, 12:14, 12:21, … 12:49, 12:56
                    and the next day 12:00 again          (not "every 7 minutes")

0 0 28-31 * *     → Sat 28 Nov, Sun 29 Nov, Mon 30 Nov, Mon 28 Dec, …
                    (not "the last day of the month")

The */7 case catches people out: a step restarts at the beginning of the field every hour (or every day, month…), so any step that does not divide 60 evenly leaves a short gap at the boundary. */7 fires at :56 and then at :00 of the next hour, four minutes later. For a true fixed interval use a step that divides the field (1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30 for minutes) or a scheduler that supports intervals, such as a systemd timer with OnUnitActiveSec=7min.

The day-of-month / day-of-week OR rule

This is the most common cron misunderstanding. When both day fields are restricted, cron runs the job if either of them matches, not when both match. The behaviour is specified by POSIX and implemented by Vixie cron and cronie.

0 9 13 * 5        intended: "Friday the 13th at 09:00"
                  actual:   every Friday AND every 13th of the month
                  → Fri 13 Nov, Fri 20 Nov, Fri 27 Nov, Fri 4 Dec, Fri 11 Dec, Sun 13 Dec …

0 9 1-7 * 1       intended: "first Monday of the month"
                  actual:   every Monday, plus days 1–7 of every month

A subtle variant: Vixie cron decides whether a day field is "restricted" by checking whether it starts with *. So 0 9 */2 * 1 is treated as unrestricted on the day-of-month side, and the two conditions are combined with AND: it fires only on Mondays that fall on an odd date. Other implementations treat */2 as a restriction and use OR. Avoid mixing a step in one day field with a value in the other.

The portable fix is to leave the day-of-week field as * and test the extra condition in the command. For "first Monday of the month":

# Days 1–7 only, then let the shell check that today is Monday.
# % must be escaped in a crontab line (see the gotchas below).
0 9 1-7 * *  [ "$(date +\%u)" = 1 ] && /usr/local/bin/monthly-report.sh

Schedulers with Quartz syntax solve this with dedicated operators (MON#1 for the first Monday, L for the last day of the month), covered next.

Dialects: Unix cron vs Quartz vs cloud schedulers

A cron expression copied from one system often means something different, or is invalid, in another. Check which dialect your scheduler expects before you paste.

SystemFieldsNotable differences
Vixie cron / cronie (Linux)5Server local time (cronie also supports CRON_TZ). Day fields use the OR rule. Supports @reboot, @daily, etc.
Quartz (Java), Spring @Scheduled6–7: seconds first, optional yearQuartz requires ? in either day-of-month or day-of-week. Day of week is 1–7 with 1 = Sunday. Adds L, W and #. Spring uses 6 fields and does not require ?.
AWS EventBridge6: minutes … day-of-week, yearNo seconds field. One of the day fields must be ?. Expressions are wrapped as cron(…) and evaluated in UTC unless EventBridge Scheduler is given a time zone.
Kubernetes CronJob5Uses the kube-controller-manager time zone unless .spec.timeZone is set (stable since Kubernetes 1.27).
GitHub Actions schedule5Always UTC. Runs can be delayed during periods of high load, and the documented shortest interval is every 5 minutes.

The same "weekdays at 08:30" schedule in each dialect:

Unix cron        30 8 * * 1-5
Quartz           0 30 8 ? * MON-FRI
AWS EventBridge  cron(30 8 ? * MON-FRI *)

Watch the day-of-week numbers when converting: 1 is Monday in Unix cron but Sunday in Quartz. Using names (MON-FRI) avoids that trap in both.

@ shortcuts

ShortcutEquivalentNotes
@reboot(none)Runs once when the cron daemon starts, which is usually at boot
@yearly / @annually0 0 1 1 *Midnight, 1 January
@monthly0 0 1 * *Midnight on the 1st
@weekly0 0 * * 0Midnight between Saturday and Sunday
@daily / @midnight0 0 * * *Midnight every day
@hourly0 * * * *Minute 0 of every hour

These are extensions supported by Vixie cron, cronie and many libraries, not part of POSIX. Kubernetes accepts them too; GitHub Actions does not.

Time zones and daylight saving time

Classic cron evaluates expressions in the system's local time zone. On a server set to UTC, 0 9 * * * fires at 09:00 UTC, which is 10:00 in Madrid in winter and 11:00 in summer. Two practical rules:

  • Run servers in UTC and convert business hours yourself, or use a per-job time zone where the scheduler supports it (CRON_TZ=Europe/Madrid in cronie, .spec.timeZone in Kubernetes).
  • Avoid scheduling important jobs between 01:00 and 03:00 local time if the machine observes DST.

The reason for the second rule is documented in the Vixie cron man page: when the clock jumps forward, jobs that would have run in the skipped hour are run soon after the change; when it moves back, jobs in the repeated hour are not run twice. This only applies to jobs with a fixed hour and minute. A job like */10 * * * * just keeps following the wall clock, so it runs six fewer times on the spring-forward day and six extra times on the fall-back day.

Why a cron job does not run: a debugging checklist

  1. Unescaped %. In a crontab line, % means "newline" and everything after it is sent to the command's stdin. date +%F silently breaks; write date +\%F.
  2. Different environment. Cron runs commands with a minimal environment, typically PATH=/usr/bin:/bin and no shell profile. Use absolute paths to binaries, or set PATH= at the top of the crontab.
  3. Lost output. Output is mailed to the owner, which on most servers means it disappears. Redirect it: … >> /var/log/report.log 2>&1.
  4. Wrong crontab format. /etc/crontab and files in /etc/cron.d/ have a sixth column for the user (0 3 * * * root /usr/bin/backup). Per-user crontabs edited with crontab -e do not. Mixing them up makes cron try to run a command called root.
  5. Daemon logs. Check whether cron tried at all: grep CRON /var/log/syslog on Debian/Ubuntu, journalctl -u cron or journalctl -u crond with systemd.
  6. Missed runs are not replayed. If the machine was off at the scheduled minute, the run is skipped. For laptops or machines that sleep, use anacron or a systemd timer with Persistent=true.
  7. Overlapping runs. Cron starts a new copy even if the previous one is still running. Wrap long jobs in a lock: flock -n /tmp/backup.lock /usr/local/bin/backup.sh exits immediately if the lock is held.

Reference patterns

ExpressionRuns
*/5 * * * *Every 5 minutes
0 * * * *Every hour, on the hour
0 9-17 * * 1-5Hourly from 09:00 to 17:00, Monday to Friday (9 runs a day)
0 0 * * *Every day at midnight
15 2 * * 0Sundays at 02:15 (inside the DST danger window: move it if your server uses local time)
0 0 1 * *Midnight on the first day of each month
0 0 1 1,4,7,10 *Start of each quarter
0 0 28-31 * *Days 28–31; add a shell check for the true last day: [ "$(date -d tomorrow +\%d)" = 01 ] (GNU date)

Before deploying a schedule, paste it into the Cron Builder to see a plain-English description of each field, then compare it with what you meant, especially when both day fields are set. If you are converting a timestamp from a log to check when a job really ran, the Unix timestamp converter shows it in UTC and your local zone side by side.

Build and check a cron expression

Pick values for each field, start from a preset, and read back a description of the schedule before it goes into a crontab.

Open Cron Builder →