Cron
Also known as: Cron job, Crontab
Time-based job scheduler in Unix-like operating systems that runs commands or scripts automatically at specified times, dates or intervals.
Cron is a background service, or daemon, that executes scheduled tasks on Unix-like systems such as Linux and the BSDs. Users and administrators list jobs in configuration files called crontabs, edited with the crontab command. Each line pairs a schedule with a command. The schedule has five fields, for minute, hour, day of the month, month and day of the week, each holding a number, a range, a list or an asterisk meaning every value. The entry 0 3 * * *, for example, runs its command at 3:00 every morning. Scheduled tasks are commonly called cron jobs.
Cron has been part of Unix since the 1970s, and its name is generally traced to the Greek word for time, chronos. Several implementations followed; one written by Paul Vixie in the late 1980s became the basis for cron on many Linux distributions. Typical uses include rotating logs, running backups, refreshing data, sending reports and renewing certificates. The five-field cron expression has spread far beyond Unix and is used to schedule jobs in Kubernetes, CI services, cloud schedulers and many programming libraries.
Cron is simple and dependable but has well-known pitfalls. Jobs run with a minimal environment, so scripts that work interactively may fail under cron because of a different PATH or missing variables. Failures can go unnoticed unless output is captured or monitored. Time zones and daylight saving changes can cause jobs to be skipped or run twice, and cron does not prevent a slow job from overlapping with its next run. On systems using systemd, timer units offer an alternative with dependency handling and logging, though cron remains widely used alongside shell scripts.
Key points
- Cron runs commands on a schedule defined by five time fields in a crontab file.
- The five-field cron expression is used well beyond Unix, in container platforms and cloud schedulers.
- Cron jobs run with a minimal environment, a common source of scripts failing silently.
- Systemd timers are an alternative scheduling mechanism on many Linux systems.
Related entries
Daemon
Computer program that runs in the background, without direct user interaction, to provide services or perform tasks on Unix-like systems.
Shell Scripting
Writing programs for a command-line shell, such as Bash, that automate sequences of commands, file operations and system administration tasks.
Bash
Unix shell and command language written for the GNU Project, long the default interactive shell and scripting language on Linux systems.
systemd
System and service manager for Linux that runs as the first process at boot, starts and supervises services and bundles logging and other components.
Linux
Free and open-source Unix-like kernel created by Linus Torvalds in 1991 that underpins Android, most servers and many embedded devices.
Workflow Automation
Use of software to carry out sequences of tasks automatically, triggered by events or schedules, with little or no manual intervention.
Kubernetes
Open-source system for automating deployment, scaling and management of containerized applications across clusters of machines.
Referenced by
Other entries that discuss or point to Cron.