A reliable cron schedule starts with more than memorizing five fields. This guide explains cron syntax, shows how to translate plain-English requirements into expressions, and provides a verification checklist for time zones, daylight-saving changes, scheduler differences, and production troubleshooting.
Overview
A cron expression describes when a recurring job should run. In the traditional five-field format, the fields are read from left to right as minute, hour, day of month, month, and day of week:
* * * * * command| Field | Typical values | Useful symbols | Example |
|---|---|---|---|
| Minute | 0–59 | * , - / | 15 |
| Hour | 0–23 | * , - / | 2 |
| Day of month | 1–31 | * , - / | 1 |
| Month | 1–12 | * , - / | 1-12 |
| Day of week | Implementation-dependent, commonly 0–7 | * , - / | 1-5 |
The main operators are straightforward:
- Asterisk (
*) means every allowed value. In the minute field,*means every minute. - Comma (
,) lists specific values, such as1,15,30,45. - Hyphen (
-) defines a range, such as9-17. - Slash (
/) defines a step, such as*/10for every tenth allowed value.
Do not assume that every scheduler accepts exactly the same syntax. Some systems use six fields and include seconds; others support named months, special words, or additional operators. A cron expression generator can help with a first draft, but the target scheduler's documentation and a test run remain the final authority.
Checklist by scenario
Run once every day
For a job at 02:15 every day, use:
15 2 * * *Read it as minute 15, hour 2, every day of the month, every month, and every day of the week. Using a specific minute instead of * makes the intended schedule easier to inspect.
Run on weekdays
A common weekday schedule at 09:00 is:
0 9 * * 1-5Confirm how the scheduler numbers weekdays. Some implementations treat Sunday as 0, others accept both 0 and 7, and some provide named values. If portability matters, use the format explicitly documented by the destination system.
Run at regular intervals
To run every 15 minutes during every hour:
*/15 * * * *This means minute 0, 15, 30, and 45 of each hour. It is different from “15 minutes after the previous successful run.” Cron generally evaluates calendar times; it does not inherently track whether the previous execution finished.
Run during business hours
To run every 30 minutes from 09:00 through 17:30:
0,30 9-17 * * 1-5Check the boundary carefully. This expression includes 17:00 and 17:30, but it does not include 18:00. If the requirement is “from 09:00 until just before 18:00,” this may be appropriate; if the requirement uses a different interpretation of business hours, adjust and test it.
Run on a monthly date
To run at 03:00 on the first day of each month:
0 3 1 * *Calendar-based schedules can behave unexpectedly around short months. A job scheduled for the 31st may not run in months without a 31st, depending on the scheduler. If the business requirement is “the last day of every month,” a simple five-field expression may not be sufficient. Consider a wrapper script that checks the date, or use a scheduler with an explicit end-of-month feature.
Run on one day of the week and one day of the month
When both day-of-month and day-of-week are restricted, implementations may use an “either field matches” rule rather than requiring both fields to match. This is a significant portability concern. Test an expression such as 0 8 1 * 1 in the actual scheduler before relying on it. If the requirement is “the first Monday,” use a platform-specific feature or a command that verifies the date after cron starts the job.
What to double-check
Time zone
Identify the time zone used by the scheduler, not merely the time zone shown on your laptop. A host, container, managed workflow service, or CI runner may use UTC or another configured zone. Write the intended zone next to the expression in documentation and confirm it in the runtime environment.
Daylight-saving changes
Schedules tied to local civil time can encounter a skipped clock time when clocks move forward or a repeated clock time when they move backward. The scheduler may skip, repeat, or otherwise handle the run according to its implementation. For important jobs, decide whether the requirement is based on local time or elapsed time, then test the platform's documented behavior. UTC can simplify some machine-oriented schedules, but it may not match a user's local business deadline.
Command environment
Cron often runs with a smaller environment than an interactive shell. Use absolute paths where practical, set required environment variables explicitly, and redirect standard output and error to a controlled log. Verify the working directory rather than assuming it is the project directory.
Overlap and retries
Ask what happens if one run takes longer than the interval before the next run. Add a lock, use an idempotent job design, or configure concurrency controls where supported. Also define what should happen after a failure: immediate retry, next scheduled run, alerting, or manual recovery.
Execution history
Before deployment, calculate several upcoming run times with a trusted parser or the scheduler's preview function. Check the first run, the boundary of a range, a month transition, and a daylight-saving transition when local time is involved. A parser validates syntax; it does not prove that the command, permissions, dependencies, or business logic are correct.
Common mistakes
- Confusing “every” with “at intervals from start time.”
*/20in the minute field runs on clock minutes such as 0, 20, and 40, not necessarily 20 minutes after the job begins. - Mixing up hour and minute.
0 6 * * *means 06:00, while6 0 * * *means 00:06. - Using six fields in a five-field scheduler. An expression that includes seconds may be rejected or interpreted incorrectly when copied between tools.
- Assuming names and numbering are portable. Day and month names, Sunday numbering, and special syntax vary. Prefer documented numeric forms when moving schedules between systems.
- Ignoring missed-run behavior. A job may not run after a machine is offline during its scheduled minute unless the scheduler supports catch-up or another mechanism is configured.
- Deploying without an observable command. A schedule that triggers silently is difficult to troubleshoot. Log start time, completion, exit status, and a useful error message.
- Relying on a visual generator without checking semantics. A generator can produce valid syntax while still expressing the wrong time zone, weekday rule, or month boundary.
When to revisit
Revisit a cron expression before seasonal planning cycles, after a time-zone or infrastructure change, and whenever a workflow moves between local cron, a container platform, a CI system, or a managed cloud scheduler. Also review it after a missed run, an unexpected duplicate, a long-running job, or a change to the command's dependencies.
Use this pre-deployment checklist:
- Write the requirement in plain English, including time zone and expected boundaries.
- Identify the scheduler and confirm its field count, supported operators, weekday numbering, and day-of-month/day-of-week behavior.
- Translate the requirement into an expression and annotate each field.
- Preview upcoming run times, including edge cases such as month ends and daylight-saving transitions.
- Run the command manually with the same user, environment, permissions, and working directory.
- Decide how to handle overlap, failure, retries, missed runs, and duplicate execution.
- Configure logs and an alert or review process for failures.
- Record the expression, time zone, owner, purpose, and last verification date.
Keep the expression beside its plain-English description. When a workflow changes, update both together. That small habit makes a cron schedule easier to audit, migrate, and troubleshoot than a bare line of punctuation.