Cron expressions look compact, but a single misplaced field can run a job at the wrong minute, on the wrong day, or not at all. This practical guide explains how to read and build cron schedules, compare common cron formats, and verify timezone, daylight-saving, overlap, and missed-run behavior before a schedule reaches production.
Overview
A cron expression is a set of space-separated fields that describes when a recurring task may run. The traditional Unix and Linux crontab format uses five fields:
| Field | Allowed values | Meaning |
|---|---|---|
| Minute | 0–59 | Minute within the hour |
| Hour | 0–23 | Hour in 24-hour time |
| Day of month | 1–31 | Calendar day |
| Month | 1–12 | Month of the year |
| Day of week | 0–7 | Day of week; 0 and 7 commonly represent Sunday |
For example, 30 2 * * * means “at 02:30 every day” in the scheduler’s configured timezone. The asterisk means every permitted value. A comma selects multiple values, a hyphen defines a range, and a slash defines an interval:
0,30 * * * *runs at minute 0 and minute 30 of every hour.9-17 * * * *selects minutes 9 through 17 of every hour.*/15 * * * *runs every 15 minutes.0 9 * * 1-5runs at 09:00 on weekdays.
Do not assume that every scheduler accepts this exact format. Quartz-style expressions generally add a seconds field at the beginning and may include a year field at the end. Quartz also uses ? for an unspecified day-of-month or day-of-week field and supports special values such as L, W, and # in implementations that document them. Cloud schedulers and application libraries may use five, six, or seven fields and may restrict special characters. Always check the target scheduler’s grammar before copying an expression from a cron expression builder.
Checklist by scenario
Every few minutes or hours
- Start with the smallest required interval, such as
*/10in the minute field for every 10 minutes. - Decide whether the job should run all day or only during a window.
- Confirm that the task can finish before the next invocation, or add locking and idempotency protections.
- Test whether “every 10 minutes” means clock-aligned times such as 00, 10, 20, and 30, rather than 10 minutes after the previous run.
Once per day
- Choose a clear local time, then identify the scheduler timezone.
- Place the minute before the hour:
15 6 * * *means 06:15 daily, not 15:06. - Consider whether the operation is safe if the run is delayed, repeated, or skipped.
- For billing, reporting, or data exports, define which business date the job should process instead of relying only on the current clock.
Weekdays or selected days
Use the day-of-week field for recurring weekday work. A typical Unix expression is 0 8 * * 1-5, which selects 08:00 from Monday through Friday when the implementation uses 1–5 for those days. For a smaller set, use a list such as 1,3,5. Verify whether the scheduler accepts names such as MON-FRI; numeric and named forms are not equally portable.
Monthly or end-of-month work
0 1 1 * * runs at 01:00 on the first day of each month. “Last day of the month” is less portable: standard five-field cron does not provide one universal end-of-month token. A safer design is often to run on a known day and have the command determine whether it is the final business or calendar day, or to use a scheduler-specific feature only after confirming its documentation.
Quartz-style schedules
First identify whether seconds are required. A Quartz-style expression for 08:00 on weekdays may look like 0 0 8 ? * MON-FRI: seconds 0, minutes 0, hour 8, unspecified day-of-month, every month, and Monday through Friday. This is not interchangeable with the five-field Unix form 0 8 * * 1-5. In Quartz-style syntax, ? is meaningful; in many Unix cron implementations it is invalid.
Cloud and application schedulers
Before using a schedule in a hosted service, record four details: the number and order of fields, the accepted special characters, the timezone configuration, and the behavior when a run is delayed or missed. Some services use a six-field expression with seconds, while others use a five-field expression or a platform-specific wrapper. Treat the service documentation as the source of truth, not a generic online cron expression builder.
What to double-check
Timezone and daylight-saving transitions
“09:00” is incomplete without a timezone. A server configured for UTC may not match the business team’s local time. Prefer an explicit named timezone when the platform supports it, and document that choice beside the schedule. During daylight-saving transitions, a local time can occur twice or not occur at all. Determine whether the scheduler skips, repeats, shifts, or rejects the affected invocation. If the job must run exactly once per elapsed interval, a fixed UTC schedule may be more predictable than a wall-clock schedule.
Day-of-month and day-of-week behavior
When both day-of-month and day-of-week contain restrictions, implementations differ. Traditional cron commonly treats them as an OR condition when both are restricted: a job can run when either field matches. Other schedulers may use AND semantics or require an unspecified marker. Avoid guessing. Test an expression such as 0 9 1 * MON against the target system and confirm whether it means the first of the month or every Monday, or only Mondays that fall on the first.
Overlap, retries, and missed runs
Cron describes eligible start times; it does not automatically make a task safe. Ask what happens if an earlier invocation is still running. Use a lock, queue, unique job key, or idempotent operation where duplicate work could cause damage. Also check whether the scheduler catches up after downtime, skips missed occurrences, fires once immediately, or retries according to a separate policy. Log the scheduled time, actual start time, completion time, and a unique execution identifier.
Command environment
A cron process may have a smaller environment than an interactive shell. Use absolute paths where practical, set required environment variables explicitly, redirect output to a visible log, and make failures observable. Keep the schedule itself simple; place validation, retries, and business rules in version-controlled code. If the job sends JSON or calls an API, validate payloads and authentication separately; the JSON formatter and validator guide can help inspect structured data before it is submitted.
Common mistakes
- Reversing minute and hour: Cron reads left to right as minute, hour, day of month, month, and day of week in the standard five-field format.
- Using six fields in a five-field parser: A leading seconds field can shift every value and produce a valid-looking but incorrect schedule.
- Assuming slash syntax means a delay after completion:
*/20usually selects clock-aligned minutes, not twenty minutes after the prior run. - Ignoring the timezone: A correct expression can still run at the wrong business hour.
- Scheduling February 29 without a fallback: A date that exists only in some years needs an explicit policy.
- Relying on “last day” syntax everywhere: Tokens such as
Lare scheduler-specific. - Testing only the expression: Validate the command, permissions, environment, logs, timeout, and downstream behavior as one workflow.
- Allowing duplicate processing: A retry or overlap can create duplicate emails, records, payments, or exports unless the operation is idempotent.
For a repeatable review, write the schedule in plain language next to the expression, calculate several upcoming run times, and test it in a non-production environment. Keep the expression in version control with its timezone and operational assumptions. Documentation formatting matters too; a consistent Markdown runbook makes schedules easier to review alongside deployment notes. See the Markdown guide for developers for practical documentation patterns.
When to revisit
Review a cron schedule before seasonal planning cycles, timezone changes, migrations, and major workflow changes. Recheck it when an application moves hosts, a scheduler changes its expression format, a task gains retries, or a business deadline changes. A schedule that runs correctly in one environment may not behave the same way after a change in timezone, parser, permissions, or daylight-saving configuration.
Use this final checklist before publishing:
- Write the intended frequency and local time in plain language.
- Confirm the scheduler’s field count, syntax, and timezone.
- Generate and inspect upcoming run times, including month boundaries and daylight-saving dates.
- Define behavior for overlap, retry, downtime, and missed invocations.
- Make the command observable, safely repeatable, and independently testable.
- Record the expression, timezone, owner, and next review trigger in the project documentation.
When the schedule or the workflow changes, repeat the checklist rather than editing one field in isolation. That small habit prevents many timing errors and keeps a compact cron expression understandable months after it was created.