Understanding Linux cron (crond) and Managing Scheduled Tasks
This article explains Linux's cron daemon (crond), its role in system and user task scheduling, how to view and edit crontab files, write cron expressions, manage the crond service, and common commands for listing, locating, and removing scheduled jobs.
In Linux, scheduled tasks are controlled by the cron service (crond). The service is started by default because Linux already has many periodic jobs, and users can also create their own tasks using the crontab command.
1. Introduction to crond
crond is a daemon that executes tasks periodically or waits for events, similar to Windows Task Scheduler. After the OS installation, the service is installed and automatically started. Every minute crond checks for tasks to run and executes them.
Linux task scheduling is divided into two categories: system task scheduling and user task scheduling.
System task scheduling handles periodic system work such as flushing cache data to disk or cleaning logs. The configuration file for system tasks resides in /etc/crontab .
Task schedule file format:
cat /etc/crontab
SHELL=/bin/bashDefine a task schedule:
crontab -eNote: When defining a task schedule, it is best to use absolute paths for commands to avoid problems.
Example: Execute 123.sh at 03:00 on Tuesdays and Fridays during the 1st‑10th days of every even month, appending standard output to /tmp/123.log and error output to /tmp/456.log :
0 3 1-10 */2 2,5 /bin/bash /user/loacl/sbin/123.sh >>/tmp/123.log 2>>/tmp/456.logEnsure the service is running before using the schedule:
systemctl start crondCheck whether the service is running:
ps aux | grep cronroot
566 0.0 0.0 126232 1664 ? Ss 12:42 0:00 /usr/sbin/crond -n
root 1707 0.0 0.0 112676 984 pts/0 S+ 13:52 0:00 grep --color=auto cronList task schedules:
crontab -lLocation of the task schedule file (useful for backup):
/var/spool/cron/usernameSpecify a user:
crontab -u usernameDelete a task schedule:
crontab -rPractical DevOps Architecture
Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.