Definition
What it is
A cron job is a line in a crontab: 0 3 * * * /usr/local/bin/backup.sh means "run backup.sh at 03:00 every day". The five fields are, in order: minute (0–59), hour (0–23), day of month (1–31), month (1–12), day of week (0–6, Sunday = 0). Each field accepts ranges, lists and steps: */15 means "every 15 units", 1,15,30 means "on days 1, 15 and 30", 9-17 means "from 9 to 17".
cron is one of the oldest daemons still in production. It was written by Ken Thompson at Bell Labs in 1975, redesigned by Paul Vixie in 1987 (the version that still runs on most Linux systems), and reimplemented multiple times since (anacron, fcron, systemd timers).
Why it matters
Every non-trivial system has a class of jobs that do not respond to requests, they run on a clock: rotate logs before the disk fills, renew certificates before they expire, warm caches before the morning peak, take backups before something breaks. cron is the default tool for this class. It is not glamorous; it is the reason your disk is not full and your certificate is not expired.
cron vs systemd timers vs Kubernetes CronJob
Aspect | cron | systemd timers | Kubernetes CronJob |
|---|---|---|---|
Introduced | 1975 / 1987 | 2010 | 2014 |
Config file | crontab | unit + timer | YAML manifest |
Logging | Syslog, | journald | Pod logs |
Dependencies | None | After / Requires | |
Missed runs | Skipped | Can catch up |
|
Best for | Simple schedules | Systemd-managed services | Container workloads |
The cron daemon in the system
graph LR
T[Tick each minute] --> C[cron daemon]
C --> R[Read /var/spool/cron/*]
R --> M{Match now?}
M -->|No| S[Sleep]
M -->|Yes| E[Execute job as user]
E --> L[Log to syslog]
L --> S
style C fill:#E8F5E9
style E fill:#FFF3E0
Timeline of cron
1975 — Ken Thompson writes the original cron at Bell Labs for Version 7 Unix.
1987 — Paul Vixie writes the cron that still ships in most Linux distributions.
2010 — systemd timers ship as a systemd component.
2014 — Kubernetes ships CronJob in v1.5 (2017 GA).
2016 — cronie forked from vixie-cron; used by RHEL, Fedora.
2022 — Vixie cron 4.0 released under ISC license.
Writing safe crontab entries
Writing a crontab that survives
Absolute paths
cron has a minimal PATH.
/usr/local/bin/backup.sh, notbackup.sh.Redirect output
cron mails stdout/stderr to the owner. On a modern system without a local MTA, that mail is lost. Redirect explicitly.
Set the environment
PATH,HOME,MAILTO, and any variables your script needs. cron does not load your.bashrc.Lock overlapping runs
Use
flock -n /var/lock/backup.lockso a long-running job does not start twice.Test the schedule
Use crontab.guru or a dry-run to verify the five fields. Off-by-one errors in cron are the most expensive kind.
Common failures
Origin
Chronos is the Greek personification of time, older than the Olympians, distinct from Kairos (the opportune moment). Unix adopted the root for anything time-related: chrono, synchronize, cron. Ken Thompson chose cron for his time-based scheduler at Bell Labs in 1975. It runs on a clock, hence the name. Paul Vixie rewrote the scheduler in 1987; his version, vixie-cron, is the ancestor of most modern crons (cronie, cron on Debian, cron on macOS before launchd). The etymology is simple: a Greek god of time, in a Unix daemon.
Cron is a command scheduler. Cron reads the crontab file which contains the schedule of jobs to be executed by the cron daemon.
— Paul Vixie, cron man page, 1987 (paraphrase)
Evidence
FAQ
- What are the five fields?
minute, hour, day of month, month, day of week.
0 3 * * *= 03:00 daily.- How do I test a schedule?
Use crontab.guru, or run the command manually first with the same environment.
- Why did my job not run?
Usually: wrong path, missing environment variable, or the job ran and failed silently because stderr went to a mail address that no longer exists.
- cron vs systemd timers?
systemd timers integrate with the service manager, support dependencies and catch-up runs. cron is simpler and more portable across Unix-like systems.
Connections
FreeBSD / Vixie cron (2022). crontab(5). https://man.freebsd.org/cgi/man.cgi?query=crontab&sektion=5
crontab.guru (2024). crontab.guru. https://crontab.guru
systemd (2024). systemd.timer(5). https://www.freedesktop.org/software/systemd/man/latest/systemd.timer.html
Wikipedia (2024). cron. https://en.wikipedia.org/wiki/Cron
Etymology
Origin: borrowed
cron(noun): from Greek Chronos, the personification of time
Semantic network
● broader ● narrower ● related
Used in the garden
- Master Automated Server Backups: Your Blueprint for Unbreakable Data Control (9×)
- Master Linux Automation: Bash Scripting Secrets for Solo IT Founders (4×)
- Rsync Over SSH: The Ultimate Incremental Backup Strategy for Solopreneurs (3×)
- The 20-Line Python Script That Guards Your SaaS Uptime (and Your Sanity) (3×)
- Unleash Linux Power: Bash Scripting Secrets for LatAm Founders (2×)
- Algorithmic Arbitrage: Capitalizing on B2B Marketplace Inefficiencies (2×)
- SEO · ENDURE (1×)
- Data Alchemy: Python & Bash for Spotless CSVs, Micro-SaaS Power-Up (1×)
- The Zero-Downtime WordPress Migration Blueprint for High-Stakes Sites (1×)
Sources
FreeBSD / Vixie cron (2022). crontab(5). https://man.freebsd.org/cgi/man.cgi?query=crontab&sektion=5
crontab.guru (2024). crontab.guru. https://crontab.guru
systemd (2024). systemd.timer(5). https://www.freedesktop.org/software/systemd/man/latest/systemd.timer.html