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.

php exec'ed script timeout problem

Discussion in 'General Discussion' started by freedman, May 16, 2006.

  1. freedman

    freedman Well-Known Member

    Joined:
    Feb 13, 2005
    Messages:
    312
    Likes Received:
    1
    Trophy Points:
    18
    I'm launching a shell script in the background from php using exec("scriptname >/dev/null 2>&1 &")

    the script seems to run til it consumes about 4:27 of cpu time, then just stops.

    this doesn't seem to be a timeout that is anywhere I know of.
    when I run the same script manually from that userid it tuns to completion.

    Is there a timeout somewhere in a config file I'm missing, or is there another option to make this work?

    I'd thought about launching it as an 'at' job, but that user doesn't have permission to use at (they're running on jailshell), and I dont want to reduce security just for a script to run.
     
  2. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    Are you saying that:

    Code:
    scriptname >/dev/null 2>&1 &
    runs fine from shell but:

    Code:
    <?php
    
    exec("scriptname >/dev/null 2>&1 &");
    
    ?>
    times out?

    A good option would be to consider varies between the two environments.

    The main differences I can think of are that when under a PHP environment, server environment variables will be different to what they are when in a shell. Secondly the fact that your're executing a command from inside a PHP environment may be limiting the amount of memory avaiable to the command due to PHP memory limits.

    Care to share what the script does? That might help shed some light on the situation.
     
  3. freedman

    freedman Well-Known Member

    Joined:
    Feb 13, 2005
    Messages:
    312
    Likes Received:
    1
    Trophy Points:
    18
    it does some processing on audio files with vlc --essentially combines multiple tracks into a single downloadable mp3 file.

    it could be a php memory limitation .. It's currently 8M in php.ini, I'll try making it 12 and see if that produces more favorable results.
     
  4. freedman

    freedman Well-Known Member

    Joined:
    Feb 13, 2005
    Messages:
    312
    Likes Received:
    1
    Trophy Points:
    18
    I put the following in the php.ini file in the user directory from which the PHP file is run:
    memory_limit = 12M
    max_execution_time = 60000

    I also set the memory_limit in the sitewide php.ini

    neither seem to have made a difference. I can't imagine there's some odd shell variable controlling it that doesn't exist in the environment otherwise.
     
  5. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    You should probably make sure that WHM > Shell Fork/Bomb Protection > is disable, and that you don't have any RLimit* options at the top of httpd.conf
     
  6. freedman

    freedman Well-Known Member

    Joined:
    Feb 13, 2005
    Messages:
    312
    Likes Received:
    1
    Trophy Points:
    18
    the RLimitCPU was the culprit.. rather than remove it, I just increased it enuogh to get the job done.

    thanks for your pointers.
     
  7. docenta

    docenta Well-Known Member

    Joined:
    May 9, 2006
    Messages:
    64
    Likes Received:
    0
    Trophy Points:
    6
    Disable this : Shell Fork/Bomb Protection is a good idea ?
    What must be the values of RLimit for a VPS with 512 RAM and ~700MHz CPU ?





    Thanks.
     
  8. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    The limits you set are entirely up to you - how much memory you have is relatively irrelevant, it's how much you want to allow any child process before it dies. I would not recommend disabling the option you quoted, no.
     
  9. docenta

    docenta Well-Known Member

    Joined:
    May 9, 2006
    Messages:
    64
    Likes Received:
    0
    Trophy Points:
    6
    Do you think :

    #-
    #Rlimit added by apachelimits.pl
    #-
    RLimitMEM 2011527168
    RLimitCPU 240


    is a good levels for a VPS I have mentioned ?


    and is that option in my httpd.conf set good ? - MaxRequestsPerChild 4000


    Thanks.
     
Loading...

Share This Page