Linux Cron Guide
Cron is the standard job scheduler on nearly every Linux distribution, implemented as a daemon (crond) that wakes up every minute and checks each user's crontab for matching entries. It's been part of Unix since the 1970s and its 5-field syntax is the reference implementation that every other platform on this list either uses directly or adapts.
Syntax Notes
Standard 5-field format: minute, hour, day-of-month, month, day-of-week. Most Linux distributions ship Vixie cron or a compatible fork (cronie), both of which also support @nicknames (@daily, @reboot, etc.) and environment variable assignments at the top of the crontab.
Examples
crontab -ecrontab -l0 2 * * * /home/user/scripts/backup.sh >> /var/log/backup.log 2>&1Gotchas
- Cron jobs run with a minimal environment — no PATH beyond /usr/bin:/bin by default, so scripts that work fine in an interactive shell can fail silently under cron. Always use absolute paths or set PATH explicitly in the crontab.
- Output isn't shown anywhere by default — redirect stdout and stderr to a log file (>> log.txt 2>&1), or cron will try to email it (and silently drop it if no mail transport agent is configured).
- System-wide crontabs (/etc/crontab, /etc/cron.d/*) require an extra username field between the schedule and the command — a common source of 'my cron job never runs' bugs when copying a user crontab entry into a system one.
Best Practices
- Always redirect output explicitly and rotate the log file, rather than relying on cron's mail-based error reporting.
- Use full absolute paths for both the command and any files it references, since cron's working directory and PATH aren't the same as your login shell's.
- Check /var/log/syslog or /var/log/cron (distro-dependent) when a job doesn't seem to run — cron logs every invocation attempt there.
Frequently Asked Questions
- Where are user crontabs stored?
- Typically in /var/spool/cron/crontabs/<username> (Debian/Ubuntu) or /var/spool/cron/<username> (RHEL/CentOS). Always edit them with crontab -e rather than directly, so the cron daemon picks up changes correctly.
- What's the difference between a user crontab and /etc/crontab?
- A user crontab (edited via crontab -e) always runs as that user and has 5 fields. /etc/crontab and files in /etc/cron.d/ are system-wide and require a 6th field specifying which user to run as.
- Does cron run if the system is off at the scheduled time?
- No — standard cron requires the machine to be running at the exact scheduled minute. For laptops or machines that sleep, anacron (which catches up missed daily/weekly/monthly jobs on next boot) is the common complement.
Related Tools
Platform Guides
Cron syntax for Linux, Kubernetes, AWS, and more
Ubuntu Cron Guide
Set up and troubleshoot cron jobs on Ubuntu: installing cron, systemd service commands, crontab -e, and Ubuntu-specific gotchas.
macOS Cron Guide
How cron works on macOS, why Apple recommends launchd instead, and the Full Disk Access permission issue that silently breaks many cron jobs.