Kelly Mears

Cron

Time-based scheduling of recurring jobs, and the reasons scheduled jobs quietly stop working.

Systems & Tooling1 min read196 words9 out · 6 in
also calledScheduled jobCrontab

Cron is the traditional Unix scheduler: a table of times and commands, evaluated every minute. The name now stands loosely for any time-based job scheduling, including the various platform-specific successors.

Scheduled jobs fail more often than interactive commands, and nearly always for environmental reasons rather than logical ones. A scheduled job runs with a minimal environment: a short search path, no shell profile, no interactive session, and often a different working directory. A command that works when typed fails when scheduled because the program is not on the path, or because a credential lives in a profile that was never sourced.

They also fail silently by default. Output goes nowhere unless directed somewhere, so a job that has been failing nightly for months looks exactly like one that has been succeeding. Logging to a file, and — better — recording success somewhere observable, is what makes the difference. See Observability and Silent Failure.

The practical rules: use absolute paths, set the environment explicitly, log to a known location, make the job idempotent so a double run is harmless, and provide a way to trigger it manually so it can be tested without waiting for the schedule.

See also4

Hand-picked in the note itself — the neighbours worth reading next.

Related4

Nearby in the graph rather than deliberately chosen. Looser, sometimes surprising.

Linked from6

Notes elsewhere in the wiki that reach for this one.