Solved: cron jobs stopped working automatically ?

Today we will see an interesting bug when the cron jobs stopped working on the system automatically.

It is identified when we have multiple job schedulers available on the system.

To troubleshoot the issue, lets check how to proceed stepwise.

 

1. Check cron logs.

# cat /var/log/cron 
May  6 12:01:01 ngelinux0010 anacron[15695]: Anacron started on 2022-05-06
May  6 12:01:01 ngelinux0010 anacron[15695]: Job `cron.daily' locked by another anacron - skipping

 

2. Check the program which locked cron if its running.

[root@ngelinux0010 license_logs]# ps -ef | grep -i anacron
root      5655     1  0 May03 ?        00:00:00 /usr/sbin/anacron -s
root     17669 14292  0 15:41 pts/4    00:00:00 grep --color=auto -i anacron
[root@ngelinux0010 license_logs]#

 

3. Check anacron configuration files if available.

[root@ngelinux0010 license_logs]# ls -ltr /var/spool/anacron/
total 12
-rw-------. 1 root root 9 Apr 21 04:10 cron.monthly
-rw-------. 1 root root 9 May  2 15:41 cron.daily
-rw-------. 1 root root 9 May  5 04:03 cron.weekly
[root@ngelinux0010 license_logs]#

 

4. Search for anacron in /etc/.

# grep -ir anacron /etc/*
/etc/cron.hourly/0anacron:if test -r /var/spool/anacron/cron.daily; then
/etc/cron.hourly/0anacron:    day=`cat /var/spool/anacron/cron.daily`
/etc/cron.hourly/0anacron:/usr/sbin/anacron -s

Here we can see the anacron daemon was started by cron itself and has locked cron itself.

 

5. Move this script out.

[root@ngelinux0010 cron.daily]# mv /etc/cron.hourly/0anacron ~/

 

6. Kill anacron daemon.

[root@ngelinux0010 cron.daily]# ps -ef | grep -i anacron
root      5655     1  0 May03 ?        00:00:00 /usr/sbin/anacron -s
root     31243 29612  0 20:50 pts/4    00:00:00 grep --color=auto -i anacron

[root@ngelinux0010 cron.daily]# kill -9 5655

 

7. Restart cron service.

# service crond restart

Now cron jobs will not be skipped as anacron is stopped and its start script is removed.

5 1 vote
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments