A cron expression turns a recurring task into a compact schedule, but a syntactically valid expression can still run at the wrong time. This guide explains how to write and verify cron schedules, account for time zones and daylight-saving changes, compare common scheduler dialects, and document jobs so backups, reports, deployments, and maintenance tasks are easier to trust.
Overview
Start with the plain-language requirement before writing any symbols. Write down the intended frequency, the relevant time zone, the allowed day range, and whether the job must run exactly once or may run more often. For example: “Run the report at 08:30 every weekday in the Europe/London time zone.” That sentence is easier to review than an unexplained string such as 30 8 * * 1-5.
A traditional Unix-style cron expression usually has five fields, read from left to right:
| Field | Allowed values | Example | Meaning |
|---|---|---|---|
| Minute | 0–59 | 30 | At minute 30 |
| Hour | 0–23 | 8 | At 08:00 |
| Day of month | 1–31 | * | Any calendar day |
| Month | 1–12 | * | Any month |
| Day of week | Usually 0–7 | 1-5 | Monday through Friday in common conventions |
Common operators include * for every allowed value, a comma for a list such as 1,15, a hyphen for a range such as 9-17, and a slash for an interval such as */15. The expression 0 2 * * * means 02:00 every day in the scheduler’s time zone. The expression */10 * * * * means every ten minutes, not ten minutes after the job’s previous completion.
Use a cron expression builder or validator to generate and inspect a schedule, but treat its output as a draft. Confirm the target platform’s field count, time-zone behavior, weekday numbering, special characters, and handling of missed or overlapping runs.
Checklist by scenario
Daily or weekly maintenance
- Translate the requirement into a complete sentence, including a time zone.
- Choose a quiet period, but verify that the job does not conflict with backups, deploys, or database maintenance.
- Use an explicit minute and hour when a task should run once per day.
- Test the expression against several dates, including month boundaries and the end of a week.
Examples for a conventional five-field cron implementation include 15 3 * * * for every day at 03:15, 0 9 * * 1-5 for weekdays at 09:00, and 0 0 1 * * for the first day of each month at midnight. These examples assume the scheduler interprets the fields in the expected local or configured time zone.
Backups and reports
- Record the time zone beside the expression rather than relying on server location.
- Decide what should happen if the previous run is still active: skip, queue, or run concurrently.
- Define retry behavior separately from the schedule.
- Verify that logs, alerts, and retention rules cover both successful and failed runs.
For critical jobs, a schedule alone is not an operational guarantee. Add monitoring for missed runs, excessive duration, partial output, and repeated retries. A job that starts on time but produces an incomplete report still needs attention.
GitHub Actions and CI/CD
GitHub Actions scheduled workflows use a cron-style schedule, but the workflow context matters as much as the expression. Check which branch or revision the scheduled workflow uses, whether the workflow has the required permissions, and whether a schedule may be delayed during periods of platform load. A typical entry such as 0 6 * * 1-5 should be documented as “weekdays at 06:00 UTC” when that is the platform’s configured interpretation, rather than simply “morning.” Review the current platform documentation before relying on special syntax or operational guarantees.
Cloud schedulers and application libraries
Cloud services and libraries may add a seconds field, support a six- or seven-field format, use named months or weekdays, or offer a separate time-zone setting. Some accept extensions such as ?, L, or #; others reject them. Copying an expression between systems without checking the dialect is a common source of silent scheduling errors.
What to double-check
Time zone: Determine whether the scheduler uses UTC, the host machine’s zone, an account-level setting, or a per-job setting. “02:00 local time” and “02:00 UTC” are different requirements.
Daylight-saving time: A local time can occur twice when clocks move backward and may not occur when clocks move forward. Ask whether the platform skips, repeats, or otherwise handles an ambiguous run. If a job must run at a fixed interval, UTC may be simpler; if it must follow a business locality, configure and document that locality explicitly.
Day-of-month and day-of-week behavior: In many traditional cron implementations, when both fields are restricted, a run can occur when either condition matches rather than only when both match. This behavior is not universal, so test expressions such as 0 8 1 * 1 carefully.
Boundaries and ranges: Check whether ranges are inclusive, whether weekday 0 and 7 both mean Sunday, and whether lists can contain duplicate or overlapping values. Validate the next several run times, not just the expression’s description.
Execution semantics: Confirm what happens after downtime, a missed trigger, a timeout, or an overlapping invocation. Cron syntax controls when a trigger is evaluated; it usually does not define retries, locking, idempotency, or delivery guarantees.
Keep a short job record with the expression, plain-language schedule, time zone, owner, command or workflow, expected duration, retry policy, overlap policy, alert destination, and last validation date.
Common mistakes
- Confusing “every five minutes” with “at five-minute intervals after startup.”
*/5is aligned to the clock in the minute field. - Using six fields in a five-field scheduler. A leading seconds field may make an otherwise familiar expression invalid or shift every value.
- Assuming the developer’s time zone. Containers, hosted runners, and production servers may use UTC even when a laptop does not.
- Forgetting that commands run with a limited environment. Use absolute paths where appropriate, load required configuration deliberately, and capture standard output and errors.
- Scheduling destructive work without a safety check. Backups, cleanup, and migrations should be scoped, observable, and safe to rerun where possible.
- Testing only the expression. Also test permissions, secrets, network access, dependencies, lock handling, and failure alerts.
When debugging, first record the scheduler’s observed time zone and the next expected run. Then compare the generated run list with the requirement. If the timing is correct, move on to the command, credentials, application logs, and platform execution history.
When to revisit
Recheck a cron schedule before seasonal planning cycles, time-zone changes, daylight-saving transitions, a migration to a new scheduler, or a change in the job’s owner or business deadline. Revisit it after changing infrastructure, container images, CI/CD providers, runtime libraries, or deployment branches. Platform syntax and scheduling behavior can differ even when the expression looks unchanged.
Use this copyable documentation template for every recurring job:
Job:
Purpose:
Plain-language schedule:
Cron expression:
Scheduler and version:
Time zone:
Expected next runs:
Owner:
Command or workflow:
Expected duration:
Retry policy:
Overlap policy:
Missed-run behavior:
Success and failure alerts:
Last validated:
Next review trigger:
Before enabling the job, generate the next several occurrences with a cron expression builder or platform validator, compare them with the plain-language schedule, run the command manually in a production-like context, and confirm that an alert is raised for a controlled failure. This small review makes recurring automation easier to operate long after the original schedule was written.