Operations guide · reviewed 22 Aug 2026
Cron jobs that survive production.
The schedule is the easy line. The real job is making repeated execution safe, observable and boring — including the run that starts twice and the run that never starts.
01
Write the run contract first
Before choosing a schedule, write down what one run owns: its input window, output, maximum duration, retry rule and the person or system that notices failure. “Every night” is not a contract.
- Idempotency
- Running twice for the same window must either produce the same result or detect that the work is already complete.
- Overlap
- Choose explicitly: prevent overlap with a lock, queue the next run, or allow safe concurrency.
- Time
- Name the timezone. If the business rule means “midnight in Berlin”, document how daylight-saving changes are handled.
- Failure
- Return a non-zero exit status, retain useful logs and alert on the absence of an expected success marker.
02
A small host-owned job
A POSIX crontab entry consists of a schedule followed by a command. Cron does not give the process your interactive shell assumptions. Use absolute paths, set the working directory deliberately and keep secrets out of the command line.
# 02:15 every day; wrapper owns locking, logs and exit status
15 2 * * * /srv/reporting/bin/run-daily-reportKeep the crontab thin. Put environment validation, locking and the actual command in a versioned wrapper that can also be run manually. Redirecting everything to a forgotten file is not monitoring.
03
When the job belongs to a cluster
Kubernetes CronJob creates Jobs on a repeating schedule. Its documentation is explicit that scheduling is approximate: under some circumstances a schedule can create more than one Job or none. The workload therefore still has to be idempotent.
04
The handoff checklist
- The command works from a clean, non-interactive environment.
- The job has an explicit timezone and input window.
- A lock or concurrency rule is tested.
- Retries cannot duplicate irreversible side effects.
- Logs contain a run identifier, start, finish and outcome.
- An alert detects both failure and missing execution.
- A manual runbook explains replay and rollback.
05
Why this URL exists
The former PerlCoders site published a crontab tutorial at /main/crontab.html. A live external citation still points there. This is a new guide for the same scheduling intent; it does not copy the archived tutorial or its code.