oarecare Posted November 24, 2008 Share Posted November 24, 2008 i have some bad-written php scripts that, when run, make apache use over 90% cpu, under 1% memory, and not die (i have changed the timeouts to 4 seconds). The process will show in 'top' for hours, until a manual apache stop - apache start. Which part of the configuration files have i written wrong? Quote Link to comment https://forums.phpfreaks.com/topic/134030-httpd-process/ Share on other sites More sharing options...
JonnoTheDev Posted November 24, 2008 Share Posted November 24, 2008 Set max_execution_time in php.ini Quote Link to comment https://forums.phpfreaks.com/topic/134030-httpd-process/#findComment-697845 Share on other sites More sharing options...
oarecare Posted November 24, 2008 Author Share Posted November 24, 2008 it is set to 5... a reasonable amount apparently, it was a loop that php does not resume from, even though max_execution_time passes for($i=0;$i<5;$i++) { //some sort of database query //calculations $i=0; } strange, i thought max_execution_time would kill the script, but infact it won't. Quote Link to comment https://forums.phpfreaks.com/topic/134030-httpd-process/#findComment-697850 Share on other sites More sharing options...
corbin Posted November 24, 2008 Share Posted November 24, 2008 for($i=0;$i<5;$i++) { //some sort of database query //calculations $i=0; } Why would you ever do that? While i is less than 5 { //do something //set i to 0 } If I remember correctly, the max_execution_time is ignored by the PHP CLI. You should fix your loop so the script terminates when it's done doing its thing. Or, if you actually want it to run forever, put in a small pause to keep the CPU down. usleep(50) or something. Quote Link to comment https://forums.phpfreaks.com/topic/134030-httpd-process/#findComment-698187 Share on other sites More sharing options...
oarecare Posted November 24, 2008 Author Share Posted November 24, 2008 it's not my script. actually it worked like this: //check how many months have passed (mysql) for($i=0;$i<$months;$i++) { //blabla $i=0; } Of course it worked for the first month... it's not cli, it's cgi Is there any workaround to get the server to drop it after x seconds??? I hate having to debug someone else's script. Quote Link to comment https://forums.phpfreaks.com/topic/134030-httpd-process/#findComment-698210 Share on other sites More sharing options...
JonnoTheDev Posted November 25, 2008 Share Posted November 25, 2008 cgi should be dropped if it exceeds the apache TimeOut directive. If not set this defaults to 300 seconds. Quote Link to comment https://forums.phpfreaks.com/topic/134030-httpd-process/#findComment-698658 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.