ensuring that PHP is given unlimited execute

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
jasongr
Forum Contributor
Posts: 206
Joined: Tue Jul 27, 2004 6:19 am

ensuring that PHP is given unlimited execute

Post by jasongr »

Hi people

I have a PHP scripts that needs to perform a lot of work.
I need to make sure that the script will never timeout and will never stop its execution in the middle.
I tried something like:

Code: Select all

ini_set('max_execution_time', 36000);	// 10 hours
set_time_limit(0);
$original_ignore_user_abort = ignore_user_abort(false);
// a lot of work here....
ignore_user_abort($original_ignore_user_abort);
However, sometimes it doesn't work, and the script stops after a while.
Am I doing something wrong? Can anyone suggest a better approach?

regards
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

What does your error log say?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Are you running this via the command line? If so, there is no timeout.

Check your log like ~feyd said. If that turns up nothing, dump a bunch of output from different points in your script to see what gets executed & what doesn't.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

Are you on a shared host?

Many shared hosting serviced have the ability to set the timeout disabled. You can try to set it but it never really changes it. They do this to prevent one of the shared clients from taking over a server with a run away program.
jasongr
Forum Contributor
Posts: 206
Joined: Tue Jul 27, 2004 6:19 am

Post by jasongr »

Hi, I am on a dedicated server.
I see no error in the log file
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Just to be sure, trigger an error deliberately and exame the log again. Is the error there?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

jasongr wrote:Hi, I am on a dedicated server.
I see no error in the log file
Change the setting in the php.ini file then. Restart apache (or whatever web server you are running) when finished.
choppsta
Forum Contributor
Posts: 114
Joined: Thu Jul 03, 2003 11:11 am

Post by choppsta »

However, sometimes it doesn't work, and the script stops after a while.
When you say the script stops after a while, why exactly does it stop, what's the error?

The reason I say this is because it could be nothing to do with the execution time and could be that you've run out of memory or something.
Post Reply