A reliable cron schedule starts with more than five symbols: you need a clear time zone, an understanding of the scheduler’s dialect, and a quick test against the moments when the job should and should not run. This guide provides a reusable method for building minute, hourly, daily, weekly, monthly, and weekday schedules, with practical checks for UTC, local time, daylight-saving changes, and cloud scheduler differences.
Overview
A traditional cron expression uses five fields in this order:
minute hour day-of-month month day-of-week
| Field | Typical values | Meaning |
|---|---|---|
| Minute | 0–59 | Minute within the hour |
| Hour | 0–23 | Hour using a 24-hour clock |
| Day of month | 1–31 | Calendar day |
| Month | 1–12 | January through December |
| Day of week | 0–7 | Often Sunday through Saturday; 0 and 7 may both represent Sunday |
Common operators include an asterisk for every allowed value, a comma for a list, a hyphen for a range, and a slash for an interval. For example, */15 in the minute field means every 15 minutes, while 1-5 in the weekday field commonly means Monday through Friday. Names such as MON or JAN are accepted by some implementations, but numeric values are often easier to move between systems.
Before writing an expression, define the schedule in plain language. “Run the report at 06:30 every weekday in the business’s local time” is testable. “Run the report every morning” leaves the time zone, weekday behavior, and expected frequency unclear.
For a browser-based workflow, a cron expression builder and tester can help translate plain-language intent into an expression and show upcoming run times. Treat the result as a verification aid, not as a replacement for checking the scheduler’s own documentation.
Checklist by scenario
Every minute, every few minutes, or every hour
Use these patterns as starting points:
* * * * *— every minute.*/5 * * * *— every five minutes.0 * * * *— at minute zero of every hour.15 * * * *— at 15 minutes past every hour.
Ask whether the job can overlap with itself. A task scheduled every five minutes may still be running when the next invocation arrives. If overlap is unsafe, add an application-level lock, a queue, or a platform feature that prevents concurrent runs. The cron expression controls when an attempt is made; it does not automatically guarantee that only one copy runs.
Daily schedules
For a job at 02:30 every day, use:
30 2 * * *
For 18:00 every day, use:
0 18 * * *
Confirm whether “daily” means server time, UTC, or a named local time zone. A schedule that looks correct can run at an unexpected local hour if the host is configured for UTC or if the cloud service interprets the expression in a different zone.
Weekly and weekday schedules
To run at 09:00 Monday through Friday, a common expression is:
0 9 * * 1-5
To run at 23:30 every Sunday, use:
30 23 * * 0
Day-of-week numbering is not identical across every scheduler. Some use 0 or 7 for Sunday; others support names; some cloud systems expose a separate schedule configuration rather than accepting the same five-field syntax. Verify the accepted range before deploying.
Monthly schedules
To run at 04:00 on the first day of each month:
0 4 1 * *
To run at 17:45 on the 15th of each month:
45 17 15 * *
Be cautious with expressions such as “the last day of the month.” Standard five-field cron does not provide one universal last-day operator. Depending on the implementation, you may need a special extension, a wrapper script that checks the date, or a scheduler feature designed for calendar rules. Test February and shorter months rather than assuming every month contains the selected day.
UTC schedules
UTC is often a useful choice for infrastructure tasks that should occur at a globally consistent instant. If a job must run at 03:00 UTC, document that explicitly and configure the scheduler to use UTC where the platform permits it. The expression itself may still look like 0 3 * * *; the important detail is the scheduler’s time-zone setting.
Do not label a schedule “UTC” merely because the server currently reports UTC. Record the intended time zone in the job documentation and deployment configuration. This makes a future host migration or platform change easier to audit.
Local-time schedules
Choose a named time zone when the job follows a human or business calendar, such as a regional report delivered at 08:00 local time. The exact configuration depends on the cron implementation or cloud scheduler. Some support a time-zone field, environment setting, or scheduler-level option; others evaluate only in the host’s configured zone.
Write the requirement in both forms: “08:00 Europe/London time” or “08:00 America/New_York time,” rather than only “08:00 local.” A named zone communicates the intended daylight-saving behavior and avoids ambiguity across servers.
What to double-check
- Field count and order: Confirm whether the target accepts five fields, six fields with seconds, or a platform-specific format. A six-field expression copied into a five-field scheduler can be rejected or interpreted incorrectly.
- Time-zone source: Identify whether the schedule uses UTC, the machine’s local zone, an account setting, a container setting, or an explicit scheduler setting.
- Day-of-month and day-of-week behavior: In many traditional cron implementations, specifying both fields can mean that a match in either field triggers the job, rather than requiring both conditions simultaneously. Other systems may define this differently. Test a combined expression or avoid combining the fields when the intent is unclear.
- Daylight-saving transitions: A local time can be skipped when clocks move forward or occur twice when clocks move back. Ask what the scheduler does in each case: skip, run once, run twice, or apply a platform-specific rule.
- Command environment: Cron jobs may run with a limited shell environment, a different working directory, and a different
PATHfrom an interactive terminal. Use absolute paths where appropriate, set required environment variables deliberately, and log standard output and errors. - Permissions and credentials: Confirm which user runs the task and whether that account can read files, access the network, write output, or use the required secret. Avoid placing credentials directly in an expression or command line.
- Runtime and failure handling: Record expected duration, retry behavior, timeout rules, and notification ownership. A schedule is incomplete if nobody knows what a failed run should do.
- Upcoming run times: Generate several future occurrences, including a month boundary and a daylight-saving transition when relevant. Compare them with the plain-language requirement.
A documentation template
Keep this information beside the deployment configuration or in the team’s runbook:
- Job purpose: What does the task do, and what data or service does it affect?
- Expression: The exact cron expression or scheduler rule.
- Time zone: UTC or a named regional time zone.
- Owner: The person or team responsible for failures and changes.
- Command or entry point: The script, endpoint, or task name, without exposing secrets.
- Expected runtime: Typical duration and the maximum acceptable overlap.
- Failure response: Logging location, alert destination, retry policy, and manual recovery steps.
- Last verified: Date, scheduler implementation, and time-zone assumptions used during testing.
Common mistakes
- Confusing “every five hours” with “at five-hour intervals”:
0 */5 * * *runs at selected hours on the clock, not necessarily every five hours from the moment the job was created. - Using local time without naming the zone: “Midnight” is not portable. A host migration can change the observed run time.
- Assuming month-end support: The expression for day 31 will not represent the last day of every month in a basic five-field scheduler.
- Ignoring DST: A local schedule around the clock change needs an explicit policy, especially for billing, notifications, and data processing.
- Testing only the expression: A syntactically valid rule can still fail because of permissions, missing dependencies, an incorrect working directory, or a command that takes longer than the interval.
- Relying on informal examples: A copied expression may use seconds, a different weekday numbering scheme, or special extensions unsupported by your target platform.
- Assuming one successful run proves correctness: Check logs, exit status, output freshness, and duplicate behavior. Test the operational result, not just the trigger.
If a cron job touches scraped data or API responses, validate the downstream output as well as the schedule. A malformed response can make a correctly triggered job appear to have failed; a formatted and inspected payload can make diagnosis faster. For related debugging workflows, see the guide to formatting and validating JSON responses.
When to revisit
Recheck a cron schedule before seasonal planning cycles, before a regional daylight-saving transition, and whenever the workload, server, container, or cloud scheduler changes. Also review it when ownership changes, a command moves, a job begins taking longer, or reports arrive at an unexpected time.
Use this short pre-deployment checklist:
- State the intended schedule in plain language, including the time zone.
- Confirm the target scheduler’s field count, operators, weekday numbering, and special extensions.
- Generate upcoming run times and inspect ordinary days, month boundaries, and relevant DST dates.
- Run the command manually as the same user or service account where practical.
- Verify logging, alerting, timeout, retry, and overlap behavior.
- Record the expression, owner, expected runtime, time zone, and last verification date.
After deployment, inspect the first successful run and one failure path. When the platform or workflow changes, repeat the checklist rather than assuming the previous expression still carries the same meaning. A cron expression is small configuration, but its reliability depends on the surrounding time-zone, execution, and monitoring decisions.