execution time problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

execution time problem

Post by itsmani1 »

Hi

I want to set execution time of script like if want execute a script for 200 seconds and for other scripts it should be normal as fixed in configuration is it possible.

Like if have file a.php and file b.php
i want to set time 200 seconds for a.php
and for b.php i want to work normally as set in php settings

Please suggest me solution

Note: my server is shared.

thank you
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

set_time_limit()
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

Jcart wrote:set_time_limit()
do you think this will work considering i don't have dedicated server?

thank you
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

yes
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

Or by using .htaccess

Code: Select all

php_value max_execution_time "200"
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

thank you

one last question

can i set it for one script file or this will be for whole folder or dir?

and also Please see the code:

Code: Select all

$i=1;
while($i > 0)
{
 echo 'yes<BR/>';
}
i want the above code to run only 200 seconds and after that it should exit

is this possible?


thanks
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

I haven't done this before but it should work. Use

http://httpd.apache.org/docs/2.0/mod/core.html#files

instead of <Directory> directive
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

Timing out seems like a bit of a hack to me, but the alternative of checking the time every loops seems somewhat worse.

Maybe you could use a cron job? Or fork a process?
Post Reply