A cron job is a scheduled task mechanism in Linux and Unix-based operating systems that allows commands or scripts to run automatically at predefined times.
Cron jobs are commonly used for recurring tasks such as backups, maintenance operations, log rotation, automated emails, and script execution.
Cron operates through a background service called the cron daemon (crond). This service continuously checks cron tables (crontabs) and executes tasks when their scheduled time matches.
Each user can have their own crontab, and system-wide cron jobs can also be defined.
A cron job consists of five time fields followed by the command to execute:
* * * * * command | | | | | | | | | └─ Day of week (0-7) | | | └── Month (1-12) | | └─── Day of month (1-31) | └──── Hour (0-23) └────── Minute (0-59)
This structure enables precise scheduling from minute-level tasks to monthly or weekly jobs.
Incorrect cron job definitions may lead to unexpected behavior. The following best practices should be followed:
From a knowledge base perspective, cron jobs are a core component of server automation and operational reliability.