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
withstop
. Same applies forrestart
Ref:
- π Why crontab scripts are not working?
- π Linux Start Restart and Stop The Cron or Crond Service
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: