Postponing execution time out

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I've got a problem with a script that needs about 1 minute to run as the
max_execution_time is set to 30 seconds only. I don't have the rights to
modify the max_execution_time parameter on the server.

How can I postpone this time out ?

Many thanks in advance,


Re: Postponing execution time out

alex wrote:

Quoted text here. Click to load it

Hi Alex,


Did you try set_time_limit() from your script?
(Won't work if server runs in safe mode)

If you cannot modify php.ini AND the server runs in safe mode, you have a  
problem, unless your provider will help.

In that case: Try to make smaller tasks of the big job.

If your big job is sequential, you have to stop it after 20 secs or so (to  
be safe), SAFE THE STATE, then invoke a new PHP-script (or the same for  
that matter) that does the next 20 secs, etc.
Of course you have to come up with a mechanism to store the state. This can  
be in a session or in a database, or a file. Whatever you think is  

Parralel job:
In this case you can start up several requests at the same time.
(eg: job1: email to users who name start with a-m, job2: n-z)
Allthough it is very well possible that the jobs will both be slower because  
they run at the same time.
So maybe you have to split up a parralel job as sequential too. :-)

Just my 2 cents.

Erwin Moller

Re: Postponing execution time out

*** alex wrote/escribió (Tue, 23 Aug 2005 14:45:46 +0200):
Quoted text here. Click to load it

You may find this useful, if you're allowed to use it:


ini_set('max_execution_time', 120); // 120 seconds
ini_set('memory_limit', '64M'); // 64 MB


In either case, I highly recommend that you optimize your script. If it's a
database query, skip fields you don't need, limit returned rows to needed
records, use indexes, avoid unnecessary sortings... That can make as much
difference as going from 1 minute to 10 seconds.

-- Álvaro G. Vicario - Burgos, Spain
-- - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group

Site Timeline