Struggling to tell your APIs from your CDNs? Read our comprehensive cloud computing glossary covering the most common terms.
< Back to glossary
A Cron Job is a scheduled task in Unix-like operating systems that automates repetitive processes such as running scripts, performing backups, or sending emails at specified times or intervals. It is managed by the cron daemon (crond) and defined in a configuration file called the crontab.
Cron Daemon (crond): A background process that continuously checks for scheduled tasks in the crontab file.
Crontab File: Contains entries specifying tasks and their schedules using a specific syntax. Each line represents one task and includes six fields: Minute (0β59), Hour (0β23), Day of Month (1β31), Month (1β12), Day of Week (0β7 – Sunday can be 0 or 7).
Execution: When the current time matches an entry in the crontab file, the corresponding command or script is executed automatically.
Customizable Schedules: Tasks can run at precise times or intervals (e.g., every minute, daily, weekly).
Automation of Repetitive Tasks: Ideal for tasks like log rotation, database maintenance, and backups.
Error Logging: Outputs errors or logs to files for debugging.
Efficiency: Reduces manual effort by automating routine tasks.
Reliability: Ensures tasks are executed consistently at predefined times.
Flexibility: Supports complex schedules with advanced syntax options like ranges (1-5), lists (1,3,5), and wildcards (*).
Complex Syntax for Beginners: The crontab syntax can be difficult for new users to understand and configure correctly.
Limited Error Handling: Cron jobs do not provide built-in mechanisms for retrying failed tasks.
System-Specific Behavior: Some cron implementations may differ slightly across Unix-like systems.
A website administrator schedules a cron job to back up the siteβs database every night at midnight (0 0 * * * /path/to/backup_script.sh). This ensures that data is regularly saved without requiring manual intervention.