Cron Expression Guide: Build, Read, and Troubleshoot Schedules
cronautomationschedulingDevOps

Cron Expression Guide: Build, Read, and Troubleshoot Schedules

TToggle Top Editorial Team
2026-11-27
5 min read

Learn to write, adapt, and troubleshoot cron schedules across Linux, Kubernetes, GitHub Actions, and cloud platforms.

Writing a recurring job is easy; writing one that runs at the right time on the right platform is less so. This cron syntax guide explains how to read each field, adapt schedules for Linux, Kubernetes, GitHub Actions, and cloud schedulers, and verify time zones, overlaps, and missed runs before automation reaches production.

Overview

A traditional cron expression has five fields, read from left to right:

FieldAllowed valuesMeaning
Minute0–59Minute within the hour
Hour0–23Hour of the day, usually in 24-hour time
Day of month1–31Calendar day
Month1–12January through December
Day of week0–7Sunday is commonly 0 or 7; Monday is 1

The basic operators are useful across many cron-style schedulers:

  • * means every permitted value. * * * * * runs every minute.
  • , lists separate values. 0 9,17 * * * runs at 09:00 and 17:00.
  • - defines a range. 0 9-17 * * * runs hourly from 09:00 through 17:00.
  • / defines a step. */15 * * * * runs every 15 minutes.

Always confirm the scheduler's dialect before copying an expression. Some tools accept names such as MON or shortcuts such as @daily; others accept only numeric fields. A cron expression generator can help produce a first draft, but the platform's own parser and documentation should be the final check.

Checklist by scenario

Linux crontab

  1. Write the five fields in minute, hour, day-of-month, month, day-of-week order.
  2. Use an absolute path to the executable and, where appropriate, an absolute path to the script.
  3. Set the required environment variables explicitly. A cron process may not receive the same PATH or shell configuration as an interactive session.
  4. Redirect output to a controlled log or use a deliberate notification method so failures are visible.
  5. Check the host's local time zone and clock configuration before relying on a wall-clock schedule.

Examples: 0 2 * * * runs daily at 02:00, while 30 8 * * 1-5 runs at 08:30 from Monday through Friday.

Kubernetes CronJob

  1. Put the expression in spec.schedule, using the five-field format expected by Kubernetes.
  2. Define concurrencyPolicy deliberately. A long-running job may overlap the next scheduled run unless you choose a policy that prevents it.
  3. Set a useful startingDeadlineSeconds when a delayed start should be treated as a missed run rather than started indefinitely late.
  4. Review successfulJobsHistoryLimit, failedJobsHistoryLimit, retries, and cleanup behavior.
  5. Use the supported time-zone configuration for your Kubernetes version when a schedule must follow a named zone. Otherwise, verify the controller's time-zone behavior and document the assumption.

A Kubernetes CronJob is a request to create Jobs; it is not a guarantee that the task finishes exactly at the scheduled second. Make the workload safe to retry and avoid assuming that only one instance can ever run.

GitHub Actions

  1. Place the expression under on.schedule.
  2. Use the five-field cron format and design around the platform's documented scheduling behavior.
  3. Assume the schedule is evaluated in UTC unless the platform explicitly documents another option.
  4. Make the workflow idempotent and record the intended run time in logs.
  5. Consider repository activity, permissions, and the possibility that a scheduled run is delayed or does not begin exactly on the minute.

For schedules tied to local business hours, convert the desired time to UTC and revisit the conversion when daylight-saving rules change.

Cloud schedulers and other platforms

Cloud services often use cron-like syntax but may add a seconds field, support a named time zone, apply a default UTC zone, or use a different day-of-week convention. Before deployment, check the field count, allowed operators, time-zone setting, retry behavior, and whether a target can receive duplicate deliveries. Treat an event-driven scheduler as a delivery mechanism: the target should tolerate retries and should log an execution identifier.

What to double-check

  • Day-of-month versus day-of-week: In many traditional cron implementations, restricting both fields means the job runs when either field matches, not only when both match. Verify this behavior instead of assuming an AND relationship.
  • Time zone: Write the intended zone next to the schedule, such as “02:00 Europe/London,” rather than recording only “02:00.” If the tool supports only UTC, convert the schedule and document it.
  • Daylight-saving transitions: A local time may occur twice, or not occur at all, during a clock change. Decide whether to skip, duplicate, or anchor the task to UTC.
  • Month-end behavior: 0 0 31 * * does not run in months without a 31st day. For “last day of the month,” use platform-specific support or a daily job that checks the date.
  • Runtime and overlap: Compare the job duration with its interval. Add locking, deduplication, or a no-overlap policy when two executions would be unsafe.
  • Observability: Confirm logs, alerts, exit-code handling, and a way to distinguish “not scheduled,” “started,” and “failed.”

Common mistakes

The most frequent error is swapping fields. 0 6 * * * means 06:00, not “every six hours”; every six hours is commonly written as 0 */6 * * *. Another mistake is using a six-field expression from one product in a five-field crontab. A leading seconds field changes the meaning of every following value.

Do not rely on a developer's interactive shell environment. Cron may fail because a command is not on PATH, a relative file path resolves differently, credentials are unavailable, or the working directory is unexpected. Test the exact command under a comparable service account.

Finally, do not treat a successful scheduler trigger as proof that the work completed. The schedule may create a process, Job, workflow, or event while the actual task later fails. Monitor the result and make retries safe.

When to revisit

Recheck a cron schedule whenever its platform changes, the job moves between environments, or its time-zone requirement changes. Review it before seasonal planning cycles and before regional daylight-saving transitions if it follows local time. Also revisit schedules when a job's runtime grows, a team changes deployment tooling, or an incident reveals duplicate, delayed, or missed executions.

Use this short release checklist:

  1. State the desired frequency, local time zone, and acceptable delay in plain language.
  2. Translate that requirement into the platform's documented field format.
  3. Test several expected dates, including month boundaries and daylight-saving dates where relevant.
  4. Run the command or workload manually with production-like permissions and environment variables.
  5. Confirm timeout, retry, overlap, logging, and alert behavior.
  6. Record the expression, its plain-English meaning, the time zone, and the owner beside the configuration.

If the schedule is difficult to explain in one sentence, simplify it or add a validation step. A clear comment and a small test can prevent a recurring automation error from becoming recurring operational work.

Related Topics

#cron#automation#scheduling#DevOps
T

Toggle Top Editorial Team

Developer Tools and DevOps Editors

Senior editor and content strategist. Writing about technology, design, and the future of digital media. Follow along for deep dives into the industry's moving parts.