Skip to content

cron for Mere Mortals

cron is the clockwork that runs Unix machines when nobody is watching: a small daemon that wakes every minute, reads tables of jobs, and starts whatever is due — backups at 03:00, a sync every ten minutes, housekeeping on Sundays. It has almost no features, and that is the point. This guide explains the parts a mortal actually touches: reading and writing the schedules, surviving the environment jobs run in, keeping output and overlaps under control, and debugging the job that didn't run.

This guide assumes you use a terminal on a Linux machine and can edit a text file. Everything cron-specific — fields, spool, system tables — is explained from zero.

What this guide covers

What it doesn't cover

Mail server setup (cron hands output to one; running one is its own subject), the internals of other schedulers (at, batch, launchd, Windows Task Scheduler), and hosted "cron as a service" products. systemd timers get a comparison chapter here and their depth in the companion guide, systemd for Mere Mortals.

How to use this guide

Every command, firing, and failure in this guide was run for real on cron 3.0pl1 (Ubuntu 24.04): a daemon was started and read its tables aloud in the log, every-minute jobs fired and left timestamped files, broken tables were rejected by name, a 75-second job on a 60-second schedule skipped exactly as flock intended, and anacron ran a job once and then — correctly — not again. The example files in examples/ are the lab's own files with the lab's path prefix swapped for /home/you.

Two things the lab could not do are labelled where they belong: a @reboot job firing at a genuine system boot (the sandbox cannot reboot — but the daemon's refusal to fire one on a mere restart is captured, and it's the more useful fact), and delivery of job-output mail to a real mailbox (the lab machine has no mail system; cron's "discarding output" notice is captured instead). One more sandbox quirk, noted in the security chapter: unprivileged users' spool access was blocked by the sandbox ignoring the setgid bit, so the allow/deny chapter shows the refusals — the point of the test — verbatim, and describes the allowed case from stock-system behaviour.


Part of the series

This guide is one of the For Mere Mortals guides: plain-language guides to the tools programmers and makers use.

Related guides:

License

The writing in this guide is licensed under CC BY 4.0. Code examples and lab scripts are licensed under the MIT License.