Mark Lucernas
Jul 16, 2021

Cron

Cron Daemon

Run:

pgrep cron

If you see no number (i.e cron’s main PID), then cron is not running.

For Ubuntu/Mint/Debian based distro

/etc/init.d/cron start

## or using service utility
sudo service cron start

## or using systemctl in modern Linux
sudo systemctl start cron

For RHEL/Fedora/CentOS/Scientific/Rocky/Alma distro

/etc/init.d/crond start

## or using service utility
service crond start

## or using systemctl in modern Linux
systemctl start crond.service

To stop cron daemon, replace start with stop. Same applies for restart

Ref:

Crontab

Logging Using service

To enable cron logs

Open the file /etc/rsyslog.d/50-default.conf

Find the line that starts with:

#cron.*

uncomment the line and restart rsyslog:

sudo service rsyslog restart

You should now see cron log file in /var/log/cron.log and in /var/log/syslog everytime cron when running service cron start.


To print all cron jobs

cat /var/log/cron.log
# or
grep CRON /var/log/syslog

For continuous monitoring:

tail -f /var/log/syslog | grep CRON

Ref:


Resources