How to control execution time limitation

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
net1
Forum Newbie
Posts: 5
Joined: Mon Oct 17, 2005 9:41 am

How to control execution time limitation

Post by net1 »

Script return error and it stop run
PHP Fatal error: Maximum execution time of 30 seconds exceeded in /path/to/script.php on line 1288
Due to I don't want it to run longer than 30 secs as set max_execution_time = 30 in php.ini instead of stop and exit is there anyway to have some function to check without stop?

Informaton about the script:
- Runing on 5.2.5 with php-cli on Linux shell.
- Including with one script and it timeout when running function in this file.
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: How to control execution time limitation

Post by jaoudestudios »

Try this...

It might do the job with a small bit of tweaking.
http://www.forum.jaoudestudios.com/view ... ?f=13&t=11

It calculates the time for the page to compile so you should be able to check the time passed and then do something else if it has elapsed.
net1
Forum Newbie
Posts: 5
Joined: Mon Oct 17, 2005 9:41 am

Re: How to control execution time limitation

Post by net1 »

Thanks jaoudestudios for idea but I think it is only check excute time but it can not handle when execute time longer than limit.

Is it possible to use Exception with Maximum execution time?
Post Reply