cron
Learn how to schedule and automate tasks in Linux using cron jobs.
Task Scheduling & Management
Common commands for checking, editing, and managing crontab jobs.
Check Service Status
Ensure that the cron daemon service is installed and running.
systemctl status <service_name>systemctl status cronEdit User Crontab
Open the crontab editor for the current user.
crontab -eList Scheduled Jobs
View existing cron jobs for the current user.
crontab -lRemove All Jobs
Clear the current user’s entire crontab.
crontab -rEdit System Crontab
Open the system-wide crontab configuration file.
sudo nano /etc/crontabSyntax Blueprint
Cron jobs use a five-field time format followed by the command to execute.
# ┌───────────── minute (0–59)# │ ┌───────────── hour (0–23)# │ │ ┌───────────── day of month (1–31)# │ │ │ ┌───────────── month (1–12)# │ │ │ │ ┌───────────── day of week (0–6, Sun=0)# │ │ │ │ │# * * * * * command_to_executeScheduling Examples
Common practical examples of scheduling tasks with cron.
Run Daily at Midnight
Executes a shell script every day at 12:00 AM.
0 0 * * * <script_path>0 0 * * * /home/user/backup.shRun Every 15 Minutes
Executes a python script at a frequent interval.
*/15 * * * * <interpreter> <script_path>*/15 * * * * /usr/bin/python3 /home/user/task.pyRun Weekly Cleanup
Executes a system maintenance command every Sunday at 3:00 AM.
0 3 * * 0 <command>0 3 * * 0 root /usr/bin/apt autoremove -y