Jump to content

Recommended Posts

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?

 

 

Link to comment
https://forums.phpfreaks.com/topic/134030-httpd-process/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/134030-httpd-process/#findComment-697850
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/134030-httpd-process/#findComment-698187
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/134030-httpd-process/#findComment-698210
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.