Setting a timeout

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

User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

OK here's an idea based upon lostboy's inspiration.

Note: You'll need shell access for this to work **

Put the code (be as restrictive as you can here) into it's opwn dedicated PHP script. i.e A script that will do what you need within 30 seconds (using set_time_limit() -- wait for it I havent finished yet ;)).

Execute that script as CLI from within your main file which will need >30 seconds set_time_limit() using something like:

Code: Select all

$result = `php file_to_run.php`; //Note that backticks
Then just examine the output it gives to see if it timed out or not ;)

Could be flaky however.

** Without shell access do:

Code: Select all

file_get_contents('http://localhost/script_to_execute.php'); //Note the HTTP portion
Lemme know what happens ;)
Deelight
Forum Newbie
Posts: 10
Joined: Mon Jul 04, 2005 6:50 pm

Post by Deelight »

I will give it a try and let you guys know.
Post Reply