The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

urgent problem with cronjobs!

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

  1. Tyler11440

    Tyler11440 Registered

    Joined:
    Jun 28, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    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

    Joined:
    Oct 26, 2009
    Messages:
    24
    Likes Received:
    0
    Trophy Points:
    1
    Hi,

    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.
     
    #2 aapkapratik, Jun 29, 2010
    Last edited: Jun 29, 2010
  3. nxweb

    nxweb Active Member

    Joined:
    Oct 29, 2008
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    6
    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.
     
  4. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    7
    Trophy Points:
    0
    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?
     
Loading...

Share This Page