Page 1 of 1

ensuring that PHP is given unlimited execute

Posted: Tue Oct 17, 2006 5:42 am
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

Posted: Tue Oct 17, 2006 8:13 am
by feyd
What does your error log say?

Posted: Tue Oct 17, 2006 9:55 am
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.

Posted: Tue Oct 17, 2006 10:24 am
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.

Posted: Tue Oct 17, 2006 11:10 am
by jasongr
Hi, I am on a dedicated server.
I see no error in the log file

Posted: Tue Oct 17, 2006 11:21 am
by Ollie Saunders
Just to be sure, trigger an error deliberately and exame the log again. Is the error there?

Posted: Tue Oct 17, 2006 11:23 am
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.

Posted: Tue Oct 17, 2006 11:57 am
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.