Jump to content

Sleep and Max_Execution_Time


rantsh

Recommended Posts

Hey all,

 

I have the following code:

 

$i=0;
while($i++<15) {
   mail("[email protected]",date("d m Y H:i:s"),"This is email # $i ");
   echo "mandado $i <br>";
   sleep(60);
}

 

Now, I know my server has a 30 second max_execution_time setting... nonetheless, this code runs successfully!!!. Now, this is actually better for me (for the application I need to run)... Yet I'm concerned of why it's being allowed to run for 15 minutes if max_execution_time is set to 30.

 

PHP.NET says:

 

Any time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running.

 

But I don't see how my query could be included here, I don't have perfect english but for what I understand it means that the overhead caused by the actual action of sending the email does not affect the max_execution_time, but isn't the time the script is sleeping included either???????

 

Thx,

 

Roderick

Link to comment
https://forums.phpfreaks.com/topic/42365-sleep-and-max_execution_time/
Share on other sites

I have a suggestion:

 

try to talk to company which owns this host whether this host support/enable .htaccess.

 

if It does then your problem can be solved instead.

 

We own the server... and the process I need to run will be run from a crontab... how can I solve this through a .htaccess file?

You can put this file to in the same directory where your php script is going to run. Then in the  .htaccess file you can override max_execution_time on fly.

 

in .htaccess file

max_execution_time = 0; //none stop execution

 

you can also override other server or environment variable by using this way.

 

hahaha, if you own the server why should you do this ? If I were you I will try to use windows Task manage or *nix crontab.

hahaha, if you own the server why should you do this ? If I were you I will try to use windows Task manage or *nix crontab.

 

I'm going to use crontab, thing is that I'm required to process a different batch every X seconds in a single process (don't ask me why), which is why I'm bound to use sleep...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.