Mastering Crontab
Cron is a time-based job scheduler in Unix-like computer operating systems. Users that set up and maintain software environments use cron to schedule jobs (commands or shell scripts) to run periodically at fixed times, dates, or intervals.
Why use Cron?
- Automation: Run backups, update systems, or send emails automatically.
- Efficiency: Offload routine tasks to background processes.
- Reliability: Ensure tasks happen on time, every time.
Basic Syntax
The syntax for a cron job is:
* * * * * command_to_execute
- - - - -
| | | | |
| | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
| | | ------- Month (1 - 12)
| | --------- Day of month (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)