Cron Expressions Explained: Build Reliable Schedules Across Time Zones
cronschedulingautomationLinuxKubernetes

Cron Expressions Explained: Build Reliable Schedules Across Time Zones

FFlorence Cloud Editorial Team
2026-11-29
7 min read

Learn to write and verify cron expressions across Linux, GitHub Actions, Kubernetes, and hosted schedulers, including time zones and retries.

Cron expressions turn a short schedule into an automated task, but a valid expression can still run at the wrong local time, overlap with a previous job, or behave differently on another platform. This guide explains how to write and verify cron schedules, compare Linux cron with GitHub Actions and Kubernetes CronJobs, and use a practical checklist for time zones, daylight-saving changes, missed runs, and safe retries.

Overview

A cron expression describes when a scheduler should start a task. In the traditional Unix form, it contains five fields:

minute hour day-of-month month day-of-week
  *      *        *        *         *
  • Minute: 0–59
  • Hour: 0–23 in the usual 24-hour format
  • Day of month: 1–31, subject to the selected month
  • Month: 1–12, or names where the scheduler supports them
  • Day of week: commonly 0–7, with Sunday represented by 0 or 7 in many Unix implementations

The basic operators are widely shared, but not universally identical. An asterisk means “every allowed value,” a comma creates a list, a hyphen creates a range, and a slash creates a step. For example:

*/5  *  *  *  *

This means every five minutes in a traditional five-field scheduler. The expression 0 9 * * 1-5 means at 09:00 on weekdays, while 30 2 1 * * means at 02:30 on the first day of each month.

Before using a cron builder or a free developer tool online, identify the scheduler that will interpret the result. A visual builder can help prevent field-order mistakes, but it cannot always know whether your target platform uses UTC, a server-local time zone, a sixth seconds field, a timezone setting, or special words such as MON-FRI.

Checklist by scenario

Every five minutes, hourly, or daily

PurposeTypical five-field expressionVerification
Every five minutes*/5 * * * *Check whether the platform permits this frequency.
At the top of every hour0 * * * *Confirm the scheduler's time zone.
Every day at 02:1515 2 * * *Check what happens if 02:15 does not exist during a clock change.
Weekdays at 09:000 9 * * 1-5Confirm how the platform numbers Sunday and weekdays.
First day of each month0 0 1 * *Test around month boundaries and the intended business time zone.

Linux or Unix cron

  1. Write the expression using the five fields in minute-to-weekday order.
  2. Check the machine's configured time zone rather than assuming it matches your own.
  3. Use an explicit command path and a predictable working directory.
  4. Redirect output to a controlled log or monitoring destination.
  5. Run the command manually with the same user and environment where possible.

Traditional cron commonly evaluates a schedule with a special rule when both day-of-month and day-of-week are restricted: a matching day in either field may qualify. Because implementations and documentation differ in edge cases, avoid relying on that interaction for important schedules. If you need “the first weekday of the month,” consider scheduling more frequently and making the command itself check the date, or use a scheduler with an explicit calendar feature.

GitHub Actions scheduled workflows

GitHub Actions uses a POSIX-style cron expression in the workflow file. A schedule is placed under the workflow's on.schedule configuration, for example:

on:
  schedule:
    - cron: '15 9 * * 1-5'

Verify the platform's documented minimum interval, default time zone, and delivery behavior before treating a scheduled workflow as a precise timer. A workflow may be delayed when platform capacity or repository activity affects scheduling, so it is better suited to periodic automation than to second-by-second coordination. For deployment jobs, use permissions, environment protection, and secrets deliberately; the schedule alone is not an authorization boundary. The GitHub Actions deployment guide for Node.js apps provides related workflow practices.

Kubernetes CronJobs

Kubernetes CronJobs use a five-field schedule in the spec.schedule property:

apiVersion: batch/v1
kind: CronJob
spec:
  schedule: "*/15 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: OnFailure
          containers:
            - name: task
              image: example/task:stable

For a Kubernetes CronJob, double-check the cluster's supported time-zone configuration, controller behavior, job history limits, and concurrency policy. Choose deliberately among allowing overlapping runs, replacing an active run, or forbidding a new run while the previous one is active. Also define a reasonable starting deadline where supported and make the task safe to retry. A controller restart or temporary outage can affect when a job is observed and started.

Hosted schedulers and application queues

Hosted schedulers often add seconds, named time zones, calendar rules, retry policies, or webhook delivery. They may also use six fields, where the first field represents seconds. Never paste a six-field expression into a five-field scheduler, or vice versa. Record the provider, expression, time zone, retry policy, and destination together so another operator can audit the schedule without guessing.

What to double-check

Time zone and daylight-saving behavior

“At 09:00” is incomplete unless it includes a time zone. Write down whether the schedule follows UTC, the server's local zone, a container or cluster setting, or a named regional zone. For customer-facing or business-calendar work, a named time zone is usually easier to reason about than an implicit machine setting.

Before a daylight-saving transition, test what should happen to jobs scheduled during a skipped hour and a repeated hour. A scheduler may skip a nonexistent local time, run once, run twice, or document another rule. If duplicate execution is harmful, add an idempotency key or a lock. If missing one run is harmful, add reconciliation logic that checks the intended time window rather than assuming every trigger arrives.

Missed runs and delayed starts

Decide whether a missed run should be discarded, started late, or replayed. A task that sends a report may need a late catch-up; a task that refreshes a cache may simply run at the next interval. Store the intended execution time when possible, and make the worker distinguish a delayed trigger from a new schedule.

Overlap, retries, and idempotency

Estimate the longest normal and abnormal runtime. If a five-minute schedule starts a job that can run for ten minutes, overlap is possible. Use a distributed lock, a queue with deduplication, a platform concurrency policy, or an application-level claim on the work. Retries should be safe: repeating a database update, deployment, email, or API request must not create unintended side effects.

Environment and permissions

Scheduled processes often run with fewer environment variables, a different user, and a different working directory than an interactive shell. Use explicit configuration and least-privilege credentials. Keep secrets outside the expression and review how the scheduler injects them. For broader configuration guidance, see the environment variables and secrets workflow.

Common mistakes

  • Reading fields from left to right incorrectly: Cron starts with minutes, not seconds, in the traditional five-field form.
  • Assuming local time: Containers, CI systems, clusters, and hosted services may use UTC or an explicitly configured zone.
  • Using an unsupported special character: Question marks, hash symbols, “last day” syntax, and seconds fields are not portable.
  • Testing only the expression: A valid schedule does not prove that the command, credentials, network access, or application logic works.
  • Ignoring output and failures: Send logs and alerts somewhere operators will actually review.
  • Assuming exactly-once execution: Distributed schedulers can delay, duplicate, or miss triggers. Design the task for safe repetition.
  • Deploying without a rollback plan: A scheduled migration or cleanup task can affect production long after deployment. Start with a dry run or a narrow scope when possible.

When to revisit

Revisit a cron expression whenever the workflow, platform, or operating assumptions change—not only when the task fails. Use this short review before seasonal planning cycles, daylight-saving transitions, a server or cluster migration, a change of CI provider, or a move from local cron to a hosted scheduler.

  1. Write the intended schedule in plain language, including its time zone.
  2. Confirm the target platform's field count, allowed operators, minimum interval, and timezone rules in its current documentation.
  3. Use a cron builder or expression tester to generate the next several run times, including a month boundary and a clock-change date where relevant.
  4. Run the command in a staging environment and inspect logs, permissions, network access, and exit codes.
  5. Check overlap, retry, timeout, and missed-run behavior against the task's actual side effects.
  6. Record the expression, platform, time zone, owner, alert destination, and last review date beside the workflow.

Keep this checklist with the deployment or infrastructure configuration. When a workflow moves between Linux, GitHub Actions, Kubernetes, or a hosted scheduler, re-verify the expression instead of assuming that familiar syntax guarantees identical timing. A small schedule review can prevent a large operational surprise.

Related Topics

#cron#scheduling#automation#Linux#Kubernetes
F

Florence Cloud Editorial Team

Technical Editorial Team

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.