Page 1 of 1
endless loop
Posted: Wed Sep 19, 2007 12:59 am
by ddragas
Hi all
I'm having site that sends and receives sms messages. sms-es are beeing sent and recived in my system trough SMPP protocol that works in loop "listening" for new messages.
How can I make endless loop regarding time of execution?
should I do something with
ini_set("max_execution_time",$time_of_execution);
All suggestions are welcome
kind regards
Posted: Wed Sep 19, 2007 1:29 am
by mrkite
That will disable the time limit on a script. Although I think by default, php-cli doesn't have a max execution time.
Posted: Wed Sep 19, 2007 6:34 am
by superdezign
sleep() should also be used.
Posted: Wed Sep 19, 2007 7:51 am
by ddragas
of course
thank you both for reply
Posted: Mon Nov 05, 2007 1:06 pm
by ddragas
it has passed some time from my last post in this topic, but there are some new dilemmas on this issue
I've made some changes in my script using time loop
Code: Select all
set_time_limit(0);
do{
if ($connected == 0)
{
$smpp->Receive();
sleep(10);
}
}while(time() < (time() + 31536000));
but after few minutes script cracks and I get
Internal Server Error
what I need is endless loop that will not brake.
all suggestions are welcome
thank you in advance
Kind regards
ddragas
Posted: Tue Nov 06, 2007 2:51 pm
by ddragas
exactly loop breaks after 12 - 13 minutes.
does somebody know why?
I'm testing this local on desktop computer (WinXP + apache 2 + mysql5 + 5.027 + PHP5)
please - all suggestions are welcome
Posted: Tue Nov 06, 2007 3:18 pm
by WaldoMonster
Do you run PHP in safe mode?
From the PHP manual:
Set the number of seconds a script is allowed to run. If this is reached, the script returns a fatal error. The default limit is 30 seconds or, if it exists, the max_execution_time value defined in the php.ini.
...
Warning:
This function has no effect when PHP is running in safe mode. There is no workaround other than turning off safe mode or changing the time limit in the php.ini.
Posted: Tue Nov 06, 2007 3:18 pm
by WaldoMonster
Do you run PHP in safe mode?
From the PHP manual:
Set the number of seconds a script is allowed to run. If this is reached, the script returns a fatal error. The default limit is 30 seconds or, if it exists, the max_execution_time value defined in the php.ini.
...
Warning:
This function has no effect when PHP is running in safe mode. There is no workaround other than turning off safe mode or changing the time limit in the php.ini.
Posted: Tue Nov 06, 2007 3:21 pm
by ddragas
thank you for both replys

but safe_mode = Off
Endless Loop
Posted: Wed Nov 07, 2007 3:53 am
by willearp
Why not set a Cron on the server that calls your script, say every 30 seconds? Just be sure to limit how much work the script does each time so it has an end point
Will Earp