termEngineering & architecture

Cron Job

A task launched automatically according to a recurring time-based schedule.

Download Markdown (.md)

01What it means

A cron job is a command or workload triggered by a scheduler at times expressed with a calendar-like cron schedule. The term comes from Unix cron but is also used for equivalent managed and container-platform schedulers. Scheduling starts an attempt; it does not guarantee the task finishes, runs only once, or starts at an exact instant.[1][2]

A time expression repeatedly launches bounded work Schedule, start, record, recover, and wait for the next occurrence
  1. 01Match scheduleMinute, hour, day, month, and weekday rules
  2. 02Launch commandKnown environment, identity, path, and inputs
  3. 03Execute safelyBound runtime and make repeat effects tolerable
  4. 04Record outcomeLogs, metrics, exit status, and alerting
  5. 05Handle failureRetry, reconcile, or escalate without overlap

Cron launches commands; it does not inherently provide distributed locking, durable queues, dependency orchestration, retries, or exactly-once execution.

02Why it matters

Cron jobs automate recurring product and operational work such as reports, cleanup, billing cycles, and data synchronization. Their clock-based simplicity hides decisions about time zones, missed runs, overlapping executions, retries, and ownership.

03When to use it

Use a cron job when work should start on a predictable recurring schedule and does not require a user request. Use event-driven triggers when work depends on a state change, and use a workflow system when the task has complex dependencies, long-lived coordination, or strict execution guarantees.

04How it works

  1. Define the command, schedule, time zone, owner, inputs, and expected duration.
  2. Configure a scheduler with the execution environment and least-privilege credentials.
  3. Choose policies for late starts, missed schedules, overlap, retries, and retained history.
  4. Make the task idempotent or protect it with an appropriate concurrency control.
  5. Record each attempt and alert on missed, failed, stuck, or unexpectedly long runs.

05A practical example

Example

A subscription product schedules a daily entitlement reconciliation at 02:00 UTC. The task records its reporting window, refuses overlapping runs, safely upserts corrections, and alerts if no successful run completes by 04:00.

06Where it breaks

Schedulers can be unavailable, clocks and daylight-saving rules can surprise teams, and a task may overlap or be missed. Cron syntax varies across implementations. Time-based polling can also waste work compared with a direct event trigger.

Common mistakes

  • Assuming the scheduler guarantees exactly-once execution or successful completion.
  • Leaving the time zone implicit and mishandling daylight-saving transitions.
  • Allowing a slow run to overlap the next one without deliberate concurrency rules.
  • Monitoring task errors but not the absence of an expected run.

07Sources

  1. crontab — Schedule Periodic Background WorkThe Open Group · Technical standardcrontab — Schedule Periodic Background Work
  2. CronJobKubernetes · Official technical documentationCronJob
View saved topics

Start typing to search titles, definitions, categories, and frameworks.