What is a cron job?
A cron job is a command your computer runs on a schedule. The scheduler, cron, is a small background service (a daemon) that has been part of Unix since the 1970s and is still on nearly every Linux server.
How cron decides what to run
Cron doesn’t set alarms or count down to the next run. Once a minute it wakes up, reads the current wall-clock time and compares it with every line in every crontab. Any line whose five fields all match that minute gets started. Then cron goes back to sleep.
Step the clock below and watch four real-looking crontab lines being checked. The simulation starts on Friday 13 March 2026, which shows the day-field OR rule in action.
Two things follow from the minute-by-minute check. First, cron has no memory: if the machine is off at 02:30, the backup is simply missed (anacron and systemd timers with Persistent=true exist to catch up). Second, a job that takes longer than its interval will overlap with the next run unless you guard it, for example with flock -n /tmp/job.lock command.
For hands-on learning that sticks, ahaboo walks you through ideas like the Moon's phases, photosynthesis, and how income tax brackets really work.
Anatomy of a crontab line
# m h dom mon dow command
30 2 * * * /usr/bin/backup --full >> /var/log/backup.log 2>&1Five schedule fields, then the command, which runs through /bin/sh. The cron syntax guide covers the fields in detail, and the cron expression generator builds and checks them for you.
crontab -e: editing your schedule
| Command | What it does |
|---|---|
crontab -e | Edit your crontab (creates it if missing). Cron picks up changes on save; no restart needed. |
crontab -l | List your current jobs. |
crontab -r | Remove your whole crontab without asking. Back it up first with crontab -l > cron.bak. |
sudo crontab -u alice -e | Edit another user’s crontab. |
/etc/crontab, /etc/cron.d/ | System crontabs. These have an extra user column between the schedule and the command. |
/etc/cron.daily/ etc. | Drop an executable script here to run it daily, hourly, weekly or monthly (via run-parts or anacron). |
Why cron jobs fail silently
- Minimal environment. Cron starts jobs with a short
PATH(often just/usr/bin:/bin) and none of your shell profile. Use absolute paths, or setPATH=at the top of the crontab. - Percent signs. In a crontab command,
%means newline. Writedate +\%F. - No output capture. Append
>> /var/log/job.log 2>&1so errors are visible. - Wrong time zone. The server clock may be UTC. Check with
date, and preview runs in that zone with the generator. - Missing final newline. Some crons ignore the last line if the file doesn’t end with a newline.
Cron beyond Linux
The same five-field format schedules GitHub Actions workflows, Kubernetes CronJobs and Vercel Cron Jobs. Java schedulers use the six-field Quartz and Spring format, and AWS uses its own EventBridge cron().