Scheduling Tasks With Cron
Shell·2 min read·Jan 1, 2025
cron is a time-based task scheduler that allows developers and system administrators to automate the execution of commands and scripts at specific dates, times, or intervals, down to the minute.
These cron jobs are often used to schedule system updates, perform data backups, send emails, clear log files, and so on.
Installing cron on Linux
To install cron on Linux, you can use the following apt command:
$ sudo apt install cron -yAnd launched it as a background job (i.e. daemon) using the service command:
$ sudo service cron startNote:
cronis already included in macOS distributions.
The crontab format
The tasks managed by cron are listed in a file named a crontab, where each line represents a distinct task:
m h dom mon dow cmdWhere:
Unlock the CLI & Scripting with Bash module
Learn how to gain advanced control over the OS and automate complex routine tasks prone to manual errors with the CLI and Bash scripting.
You get immediate access to:
- 34 focused lessons across the CLI and Bash
- 4 real-world projects with commented solutions
- Ongoing updates to this bundle
- Lifetime access to this bundle