cron
Schedule commands to run automatically
TLDR
View documentation for managing cron entries
SYNOPSIS
crontab [-u user] file
crontab [-u user] { -l | -r | -e }
cron
PARAMETERS
-u user
Specifies the user whose crontab is to be used or modified. Only the superuser can use this option.
file
The name of the file to be used as the new crontab.
-l
Displays the user's crontab.
-r
Removes the user's crontab.
-e
Edits the user's crontab using the editor specified by the EDITOR or VISUAL environment variables.
DESCRIPTION
cron is a time-based job scheduler in Unix-like computer operating systems. It enables users to schedule jobs (commands or shell scripts) to run automatically at specific times, dates, or intervals. These scheduled tasks are known as "cron jobs".
The cron daemon, crond, runs in the background and wakes up every minute to check if there are any scheduled jobs to execute. It reads the configuration files, called "crontabs", which contain instructions specifying when and how to run tasks.
Each user on the system can have their own crontab, allowing them to schedule tasks to run under their own user context. The system administrator can also manage system-wide crontabs for running tasks with elevated privileges. cron is a fundamental tool for automating system administration tasks, backups, and other recurring operations.
CAVEATS
Changes to a crontab do not take effect immediately. crond checks the crontabs every minute. There may be slight variations in cron implementations across different Unix-like systems.
CRONTAB FORMAT
Each line in a crontab file represents a cron job and follows a specific format:
minute hour day_of_month month day_of_week command
For example: 0 0 * * * /path/to/script.sh runs the script at midnight every day. Fields can use wildcards (*), ranges (1-5), and lists (1,3,5).
HISTORY
cron has been a standard part of Unix systems since the early days. Its design has remained relatively stable over time, proving its effectiveness as a job scheduler. It's a core component of many Unix-based operating systems, including Linux and macOS. anacron was developed to address some limitations of cron, particularly when systems are not running continuously. cron's enduring presence demonstrates its crucial role in system administration.