Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

urgent problem with cronjobs!

Discussion in 'General Discussion' started by Tyler11440, Jun 28, 2010.

  1. Tyler11440

    Tyler11440 Registered

    Jun 28, 2010
    Likes Received:
    Trophy Points:
    I created a cron job with a loop on it that executes 10 times. I activated it and set it to run every minute. Afterwards, i realized i forgot to add a condition to the loop, so its stuck in an infinite loop and has been for 5 hours. I changed the php file but the ones that the server is already executing are stuck and i cant stop them. How do i stop cronjobs that are stuck running on the server? HELP! They are doing quite some damage! :(
  2. aapkapratik

    aapkapratik Member

    Oct 26, 2009
    Likes Received:
    Trophy Points:

    As the cron job you have set is in infinite loop and thus it is getting exeicuted since last 5 hours.

    So In my opinion stopping cron or removing the job now wont help you.

    But by using following command you can search for the exact process in loop

    # ps -faux | grep crond

    This command will show all the crond running processes on server. Look for perticular process you want to kill take its PID and kill the process Manually as

    # killall -9 PID

    If you dont have shell access to execute these commands please contact your web hosting support, they might do this for you.
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    #2 aapkapratik, Jun 29, 2010
    Last edited: Jun 29, 2010
  3. nxweb

    nxweb Active Member

    Oct 29, 2008
    Likes Received:
    Trophy Points:
    and when doing the above, make sure you restart crond afterwards :)

    But yeah, you should be able to use ps aux to find the rogue process and kill it by ID.
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. Spiral

    Spiral BANNED

    Jun 24, 2005
    Likes Received:
    Trophy Points:
    Addendum to what the others said, you can also rename, delete,
    or change the permissions to non-executable the cron script so that
    way cron can't respawn the process while you go kill the existing
    processes still running in memory.

    So basically in a nutshell ---

    1. Remove your script from being run by cron

    2. ps aux | grep (script name)

    3. Kill the processes found running

    4. Remove the cron line calling the script

    5. Restart cron

    6. Check again to make sure you got all the running processes

    Now you should be able to rewrite the script correctly and set it up in cron again. :D

    Now one thing that does have me a little concerned in what you said is that you are trying to "loop 10 times" yet running every minute. Out of curiosity, exactly what is it that you are trying to do exactly?

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice