Time limit on system call..

Discussion in 'PHP' started by digdogger, Dec 29, 2006.

  1. #1
    Hi,

    I've been using some exec() calls in php on linux to process a few images, however, occasionally, one process hangs and starts overloading the server. I know there is a set_time_limit() on PHP scripts, but, I'm wondering if there is a way to limit on the time on exec() calls.

    Does anyone have any ideas?

    Thanks

    -d
     
    digdogger, Dec 29, 2006 IP
  2. nocookies

    nocookies Peon

    Messages:
    57
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It is best to do long processing on the background (and don't let the php script wait on the execution).

    It would be best to run a script that will process in the background. You can use a cron job to kill programs that run for too long.
     
    nocookies, Dec 30, 2006 IP
  3. RobPinnacle

    RobPinnacle Active Member

    Messages:
    423
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #3
    AS nocookies said the simpliest way I know to tell you would be to set a cron job that stops the loading process. Although I would change the way your processes are set personally.
     
    RobPinnacle, Dec 30, 2006 IP
  4. Nikolas

    Nikolas Well-Known Member

    Messages:
    1,022
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    150
    #4
    On the other hand if you want to trigger the command with exec you can try something like (for linux) :

    exec('Some command  > /dev/null &');
    PHP:
    This will execute the command in the background, and your script will continue running with no problems.
     
    Nikolas, Dec 30, 2006 IP
  5. digdogger

    digdogger Well-Known Member

    Messages:
    97
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    121
    #5
    I don't want it to be done in the background.

    The command should take under 10 seconds, but occasionally goes out of control and runs for minutes.

    A cron based kill (which I'm already using) kills all the processes, not just the ones that are running long.

    Ideally, I'd just like to put a time limit on the exec call, just like php already has for the php script part.
     
    digdogger, Dec 31, 2006 IP