Why is this cron entry executed twice?

前端 未结 12 1010
栀梦
栀梦 2020-12-10 01:39
*/5 * * * * my command

This entry works but every 5 minutes it gets executed twice, why?

In /var/log/cron it shows:

         


        
12条回答
  •  抹茶落季
    2020-12-10 02:45

    Running ps -A | grep cron, killing all jobs didnt't help in my case. Problem was after killing all cron jobs and starting again with only one cron daemon I would get two cron jobs started from the same parent cron PPID - one with /bin/bash - the other one with /bin/sh

    Solution was to reboot server.

    This happened on several occasions, different OSs - centos 6 and redhat 7. Usually after online OS upgrade without reboot.

    As someone said - probably some different context.

    I saw one article on the net with same processes one with /bin/bash other one with /bin/sh at exactly same time - i thought yeeee - this is my case - but no, guy didn't even give a thought what is the root cause for such strange behavior, just started writing some script logic to make second process exit which is not really a solution.

    BTW ps -A | grep cron will also list all cron childs - normal cron jobs, more cron processes doesn't mean it is more cron daemons, might be only one daemon and others are childs.

    ps -ef | grep cron on the other hand lists only one - why? Because ps -ef lists childs as CROND - to get them all do ps -ef | grep -i cron

提交回复
热议问题