apache +php +time limits 
November 17th, 2008, 02:45 PM
| | | |
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 | 
November 17th, 2008, 11:05 PM
| | | | re: apache +php +time limits
did you restart the server after setting the max execution time? | 
November 18th, 2008, 08:45 AM
| | | | re: apache +php +time limits
macca wrote: Quote: |
did you restart the server after setting the max execution time?
| of course ... YES - i restarted ... | 
November 18th, 2008, 09:25 AM
| | | | re: apache +php +time limits
Nichu escribió: Quote:
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
-- | 
November 18th, 2008, 09:35 AM
| | | | re: apache +php +time limits
Álvaro G. Vicario wrote: Quote:
Nichu escribió: Quote:
>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 | 
November 18th, 2008, 09:45 AM
| | | | re: apache +php +time limits
Nichu escribió: Quote:
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
-- | 
November 18th, 2008, 11:35 AM
| | | | re: apache +php +time limits
Álvaro G. Vicario wrote: Quote:
Nichu escribió: Quote:
>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 | 
November 18th, 2008, 12:35 PM
| | | | re: apache +php +time limits
Nichu wrote: Quote:
Álvaro G. Vicario wrote: Quote:
>Nichu escribió: Quote:
>>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. jstucklex@attglobal.net
================== | 
November 19th, 2008, 03:35 AM
| | | | re: apache +php +time limits
>generally limit works but it doesn't last for time specified in php.ini Quote: |
>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. Quote:
>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)
| | 
November 20th, 2008, 04:45 AM
| | | | re: apache +php +time limits
Michael Vilain wrote: Quote:
In article <adv8i4l161avmrmcicl0lsj04pqg3ir6c0@4ax.com>,
nadia <nospam@example.comwrote:
> Quote:
>On Tue, 18 Nov 2008 07:29:48 -0500, Jerry Stuckle <jstucklex@attglobal.net>
>wrote:
>> Quote:
>>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. |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,662 network members.
|