By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,740 Members | 844 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,740 IT Pros & Developers. It's quick & easy.

apache +php +time limits

P: n/a
Hello
I set max_execution_time to 30 in php.ini file (i also checked in
phpinfo). max_input_time is set to 45.

But when I use in script something like that:

while ( 1 == 1 )
or
for ( $i=0; $i < 10000000000000000000000000000000000000000; $i++)

{
echo "\n".$i;
}
it doesn't work - execution of script lasts for unlimited time.

of course I executed it via apache (I read that this limit doesn't work
while executing in console)

is it bug or am i doing something wrong?

regards
nichu
Nov 17 '08 #1
Share this Question
Share on Google+
9 Replies


P: n/a
did you restart the server after setting the max execution time?
Nov 17 '08 #2

P: n/a
macca wrote:
did you restart the server after setting the max execution time?
of course ... YES - i restarted ...
Nov 18 '08 #3

P: n/a
Nichu escribió:
I set max_execution_time to 30 in php.ini file (i also checked in
phpinfo). max_input_time is set to 45.

But when I use in script something like that:

while ( 1 == 1 )
or
for ( $i=0; $i < 10000000000000000000000000000000000000000; $i++)

{
echo "\n".$i;
}
it doesn't work - execution of script lasts for unlimited time.

of course I executed it via apache (I read that this limit doesn't work
while executing in console)
I suppose you've already checked the most obvious things (restart web
server, run phpinfo() to see if your settings have been applied...).

An alternative could be to use this in the code itself:

<?php
ini_set('max_execution_time', 30); // Seconds
while(TRUE){
}
?>

It works for me where editing php.ini doesn't (e.g. console).
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
Nov 18 '08 #4

P: n/a
Álvaro G. Vicario wrote:
Nichu escribió:
>I set max_execution_time to 30 in php.ini file (i also checked in
phpinfo). max_input_time is set to 45.

But when I use in script something like that:

while ( 1 == 1 )
or
for ( $i=0; $i < 10000000000000000000000000000000000000000; $i++)

{
echo "\n".$i;
}
it doesn't work - execution of script lasts for unlimited time.

of course I executed it via apache (I read that this limit doesn't
work while executing in console)

I suppose you've already checked the most obvious things (restart web
server, run phpinfo() to see if your settings have been applied...).

An alternative could be to use this in the code itself:

<?php
ini_set('max_execution_time', 30); // Seconds
while(TRUE){
}
?>

It works for me where editing php.ini doesn't (e.g. console).

of course I checked phpinfo - i also checked ini_get - and both methods
show me good value (the one I set in php.ini)

ini_set works for me - but i want to limit execution time for all my
users - and rather if I tell them to add this line to their scripts they
won't listen to me ;)

so I need to do it via php.ini

Nov 18 '08 #5

P: n/a
Nichu escribió:
ini_set works for me - but i want to limit execution time for all my
users - and rather if I tell them to add this line to their scripts they
won't listen to me ;)

so I need to do it via php.ini
Weird... What OS and server API are you using?
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
Nov 18 '08 #6

P: n/a
Álvaro G. Vicario wrote:
Nichu escribió:
>ini_set works for me - but i want to limit execution time for all my
users - and rather if I tell them to add this line to their scripts
they won't listen to me ;)

so I need to do it via php.ini

Weird... What OS and server API are you using?

uppps
it was wrong diagnosis :/ sorry for that...
generally limit works but it doesn't last for time specified in php.ini
and it lasts ... well rather quite randomly ...

when I set the limit to lower value (3 seconds) firstly it stopped
script after 7 seconds, 2nd time after ~12 seconds, 3rd time ~9 seconds
and later it last really long (after 25 seconds I stopped it manually)

probably it has something common with caching but generally sometimes it
lets script working for really long time (much longer than limit in
php.ini stands for)

by the way i'm testing it on mandriva, debian and gentoo...

regards
nichu
Nov 18 '08 #7

P: n/a
Nichu wrote:
Álvaro G. Vicario wrote:
>Nichu escribió:
>>ini_set works for me - but i want to limit execution time for all my
users - and rather if I tell them to add this line to their scripts
they won't listen to me ;)

so I need to do it via php.ini

Weird... What OS and server API are you using?


uppps
it was wrong diagnosis :/ sorry for that...
generally limit works but it doesn't last for time specified in php.ini
and it lasts ... well rather quite randomly ...

when I set the limit to lower value (3 seconds) firstly it stopped
script after 7 seconds, 2nd time after ~12 seconds, 3rd time ~9 seconds
and later it last really long (after 25 seconds I stopped it manually)

probably it has something common with caching but generally sometimes it
lets script working for really long time (much longer than limit in
php.ini stands for)

by the way i'm testing it on mandriva, debian and gentoo...

regards
nichu
3 seconds does not necessarily mean 3 real-time seconds. It means at
least 3 seconds of cpu time - which varies in real life, depending on
what else is going on in the system.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Nov 18 '08 #8

P: n/a
>generally limit works but it doesn't last for time specified in php.ini
>and it lasts ... well rather quite randomly ...
As I understand it, the execution time limit is in CPU seconds, not
wall clock seconds, and only for the PHP process. So if your script
is doing a lot of stuff that doesn't occupy much CPU (*in PHP*),
such as disk I/O, network I/O, DNS lookups, or database calls, it
may last quite a bit longer.
>when I set the limit to lower value (3 seconds) firstly it stopped
script after 7 seconds, 2nd time after ~12 seconds, 3rd time ~9 seconds
and later it last really long (after 25 seconds I stopped it manually)

probably it has something common with caching but generally sometimes it
lets script working for really long time (much longer than limit in
php.ini stands for)
Nov 19 '08 #9

P: n/a
Michael Vilain wrote:
In article <ad********************************@4ax.com>,
nadia <no****@example.comwrote:
>On Tue, 18 Nov 2008 07:29:48 -0500, Jerry Stuckle <js*******@attglobal.net>
wrote:
>>3 seconds does not necessarily mean 3 real-time seconds. It means at
least 3 seconds of cpu time - which varies in real life, depending on
what else is going on in the system.
Really?
Can you tell me where that is documented lease?
(I've never heard of a timer using the CPU before)

nadia.

You didn't look very far:

http://www.php.net/manual/en/functio...time-limit.php
Pull up that page and search for 'CPU', it's there for sure. Thanks for
a lil bit of knowledge ill need down the road.
Nov 20 '08 #10

This discussion thread is closed

Replies have been disabled for this discussion.