CRON Job Management

A cron job is a scheduled task in Linux/Unix-like systems that runs automatically at specified intervals. It’s managed by the cron daemon (crond) and is configured through the crontab file.

Syntax for cronjob

How to create a CronJob

crontab -e
* * * * * command_to_run

Sample

# Run a script every day at midnight
0 0 * * * /path/to/script.sh

# Run a Python script every 15 minutes
*/15 * * * * /usr/bin/python3 /path/to/script.py

#Run a backup every Sunday at 2 AM
0 2 * * 0 /path/to/backup.sh

Frequently used Cronjob Commands

crontab -ecreate Cronjob
crontab -lCheck existing cron jobs with
export VISUAL=nano
export EDITOR=nano
Set Nano as the Default Editor
sudo systemctl restart crond
sudo systemctl restart cron
Restarting the Cron Service
sudo yum install cronie

sudo apt-get update
sudo apt-get install cron
Install Cron
sudo systemctl start crondstart the cron service
sudo systemctl status cron # For Debian/Ubuntu
sudo systemctl status crond # For RedHat/CentOS
Verify Cron is Running
grep CROND /var/log/cron

grep CRON /var/log/syslog
Check System Log Files
tail -f /var/log/syslog # For Debian/Ubuntu
tail -f /var/log/cron # For RedHat/CentOS
Viewing Crontab Log in Real-Time

Note :

On Debian/Ubuntu-based systems, cron is usually named cron or crond.

On RedHat/CentOS-based systems, it’s often named crond.

Leave a Reply

Your email address will not be published. Required fields are marked *