Cron job stops responding

Discussion in 'Site & Server Administration' started by grutland, Feb 19, 2011.

  1. #1
    Hi,

    I seem to be having a reoccuring problem with one of my cronjobs.
    The script itself is written in PHP.
    It creates a log file of where abouts in the script it is as it's running but it doesn't give any reason why it's happening.

    Basically, it just stops responding and sits there doing nothing until I kill the process.
    Does any one know why this might happen?
    Or if there is a way of restarting a con job from the last known place?

    Cheers,
    Gary
     
    grutland, Feb 19, 2011 IP
  2. mellow-h

    mellow-h Peon

    Messages:
    750
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If the cron is running and waiting, that means your cronjobs daemon is working just fine. You would probably want to run a strace to see what for it is waiting. If you would like to restart the cronjob daemon, you can do this via:

    service crond restart
    Code (markup):
    Good luck.
     
    mellow-h, Feb 19, 2011 IP
  3. RoseHosting

    RoseHosting Well-Known Member

    Messages:
    230
    Likes Received:
    11
    Best Answers:
    11
    Trophy Points:
    138
    #3
    You can include these lines of code in order to display error messages caused by your PHP script:

    ini_set('display_errors',1);
    error_reporting(E_ALL);

    Or, you can edit your php.ini file and include this option:

    error_reporting = E_ALL

    Also, check the cron job itself.
     
    RoseHosting, Feb 24, 2011 IP
  4. grutland

    grutland Active Member

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #4
    Thank you for the suggestion, but I do already have error_reporting set to E_ALL as well as my own function to deal with errors and it's not reporting any errors.
    How do I check a cron job?

    I have been reading more and found out about 2>&1 so tried adding a log file to the end of my cron job:
    > /path/to/log_file 2>&1

    This actually worked for one attempt, it ran the script with out any issues and got all the way through.
    Although when I next ran the script I started getting the same problem, it just stops responding.

    I have a check in my script to test for server load and if it gets too high it pauses the script using time_sleep_until(), I was using sleep() but read about being interupted by server signals.
    Does this mean any thing to any one?
     
    grutland, Feb 25, 2011 IP
  5. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #5
    Is the script using cURL? I had an issue months ago where a cURL request that didn't have any timeouts set through the options was causing my cron job to hang indefinitely.
     
    joebert, Mar 5, 2011 IP