Cron Job
A task launched automatically according to a recurring time-based schedule.
Download Markdown (.md)Soroush’s Product Wiki · https://wiki.soroush.uk/topic/cron-job/
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]
- 01Match scheduleMinute, hour, day, month, and weekday rules
- 02Launch commandKnown environment, identity, path, and inputs
- 03Execute safelyBound runtime and make repeat effects tolerable
- 04Record outcomeLogs, metrics, exit status, and alerting
- 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
- Define the command, schedule, time zone, owner, inputs, and expected duration.
- Configure a scheduler with the execution environment and least-privilege credentials.
- Choose policies for late starts, missed schedules, overlap, retries, and retained history.
- Make the task idempotent or protect it with an appropriate concurrency control.
- Record each attempt and alert on missed, failed, stuck, or unexpectedly long runs.
05A practical 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
- crontab — Schedule Periodic Background WorkThe Open Group · Technical standardcrontab — Schedule Periodic Background Work
- CronJobKubernetes · Official technical documentationCronJob