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 Process dies after 5 mins

Discussion in 'General Discussion' started by Matt Wade, Jun 17, 2007.

  1. Matt Wade

    Matt Wade Member

    Joined:
    Jul 22, 2004
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    I have a client that is running a php script that does a rather large import of data into a MySQL database. It runs fine until he starts dealing with larger data sets that take more than 5 minutes to process. At exactly the 5 minute mark, the process just stops. No error messages to be found anywhere. He is setting the PHP time limit (set_time_limit) to 0, which should disable the time limit restriction in PHP itself.

    My question is, does anyone know of anything within cPanel that will kill a process at the 5 minute mark? I've been unable to locate anything as of yet.
     
  2. ckh

    ckh Well-Known Member

    Joined:
    Dec 6, 2003
    Messages:
    356
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Phoenix, AZ
    cPanel Access Level:
    DataCenter Provider
    In the http.conf there is a 300 second default timeout setting. There's nothing in cPanel that you can set to change that, you have to change it in http.conf and restart apache.
     
  3. GeeBee

    GeeBee Registered

    Joined:
    Jun 18, 2007
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    If your PHP Server is not running in safe mode, you'll find set_time_limit(); may help.

    See http://www.php.net/manual/en/function.set-time-limit.php

    I had a similar problem in a shared hosting environment and so could not change Apache http.conf or use max_execution_time();

    I called set_time_limit(120); every so often during my script and had a win :)

    Hope this helps
     
  4. Matt Wade

    Matt Wade Member

    Joined:
    Jul 22, 2004
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Thank ckh...I didn't think about the apache timout setting. I'm thinking that is the most likely culprit. I'm not so sure I really want to raise that setting server wide though, so the client may just need to determine another way to do this. Scheduling a cron to run would probably work as it then wouldn't go through apache.

    Thanks again!
     
  5. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    You might also want to check the max_execution_time in /usr/local/lib/php.ini and if it's set to something like 300 seconds, I would suggest creating a .htaccess for that one site that contains "php_flag max_execution_time 600" or something of that nature.

    Another possibility is that mySQL itself is timing it out.
     
  6. Serra

    Serra Well-Known Member

    Joined:
    Oct 27, 2005
    Messages:
    213
    Likes Received:
    4
    Trophy Points:
    18
    Location:
    Florida
    Its also possible that an external app is stopping processing, like prm or other process monitor.

    I've found that my PHP processes do have a finite processing max, beyond what would be in a conf or php.ini. I've also found that it different if it is running under a cron or not.

    The work around for this is to break the process down into smaller more manageable processes, which has worked well for me. Also, if the process is running 5 minutes, it may well be that it is some what inefficient and some efficiency would be an improvement.
     
Loading...

Share This Page