PHP max_execution_time

Hello,

I need help in figuring out how max_execution_time and set_time_limit effect each other.
here is the scenario:
I’m sending mass email to 90 000 member (not spam), however after some time i’m getting Operation Timeout message from the browser.
after researching i thought that maybe max_execution_time might be the problem, when checked the php.ini file it was set to 30. My question is: if i set it to 1800 would this be enough for my script not timing out?
or i should be using set_time_limit also?

my second question please, is there a very simple php script which basically do nothing but test what my execution time limit is? like a script that runs without doing anything until the execution time limit is reached and its timedout.

thank you a lot for the help!

hello,

By default all max_execution_time is 30 unless you change it to adjust your needs.

if i set it to 1800 would this be enough for my script not timing out?

you can asnwer that question yourself by trying it, if you dont get max excution error you can go ahead and reduce the max_execution_time to let’s say 600 and keep trying until you get the perfect time out limit

thank you wilson!

so i don’t need to use set_time_limit? max_execution_time would do the job?
also can you please provide me or guide me for the script i talked about:

my second question please, is there a very simple php script which basically do nothing but test what my execution time limit is? like a script that runs without doing anything until the execution time limit is reached and its timed out.

thanks again

You want to output to he browser so it does not timeout.
This does not mean the script has stopped running but the output has the script could very well be running still.
You would use obj_flush(); to do this.

This is an example but it will not work as it needs a count for $i.
Its just to give you an example to go from.

[php]
// add to the top of script
ob_end_flush();
ob_implicit_flush(true);
ob_start();

// add to the script that is looping with a count
echo '. ';
if ($i % 10 == 0) {
ob_flush();
flush();
}

[/php]

thank you noodles!

I was able to run this script to check
[php]<?php

// current time
echo date(‘h:i:s’) . “\n”;

// sleep for 65 seconds
sleep(65);

// wake up !
echo date(‘h:i:s’) . “\n”;

?>[/php]

it has worked for me as long as i gave sleep a value under 60.
If i give it a value above 60 (like now 65) i would get Operation Timed Out error from the browser.
I have edited my php.ini and set the max_execution_time to 3600 and the max_input_time to 3600
I also even changed the apache configuration TimeOut to 3600
I have restarted apache and I’m still getting the same error.

any idea why im still timing out?
It should be able now to handle sleep(65)

This is not a good idea to run it ith a time out that large, you could restart thje script again but the script will still be running like I said before.

You need to update the browser before it times out have you ever seen a script that ouputs dots to the browser in lines …

This is outputing to the browser so it will not time out till the script has finished.

you can send 1 dot for every 100 loops so it will put 1 dot for every 100 mail sent look at flush function output to browser.

Yes, the problem is that the script is extremely complicated so its hard for me to modify it in order for it to not “timeout” on me and here is the script:
pastebin.com/ZWtLWRBy
once done it should return to a page where it shows successfully send or similar…

note: yes, i just wanted to put the timer on a high number thinking maybe this would help the 65s script display the output (which is the time of start and end) and that failed… even firefox timeout time is set higher then 65s… still timing out.)

really thank you for the help :slight_smile:
please let me know if i can make your method work with this script.

You will have to do this I am not going to do it for you, I gave you the functions and how to do it you can do it.

thanks noodles!
I just dont get why
[php]<?php

// current time
echo date(‘h:i:s’) . “\n”;

// sleep for 65 seconds
sleep(65);

// wake up !
echo date(‘h:i:s’) . “\n”;

?>[/php]

isnt working…

it worked on my second server which is Debian without any code change.
it just didnt work on my CentOS one.

help please :frowning:

You could just make a count for every loop you do.
Then every time it goes to the loop it will count to the browser which would stop it from timing out.
You must have a loop in your code some place to send each email.
Have you made sure the php.ini are the same for both servers maybe a server config problem if it runs on one and not on the other do they have the same php version ?

[php]$i=1;
loopstart {
$i++;
echo $i;
} [/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service