Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 23rd, 2005, 01:55 PM
alex
Guest
 
Posts: n/a
Default Postponing execution time out

Hi,

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,

--
alex


  #2  
Old August 23rd, 2005, 02:05 PM
Erwin Moller
Guest
 
Posts: n/a
Default Re: Postponing execution time out

alex wrote:
[color=blue]
> Hi,
>
> 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,
>
> --
> alex[/color]

Hi Alex,

Check
http://nl2.php.net/function.set-time-limit

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.

Sequential:
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
suitable.

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.

Regards,
Erwin Moller
  #3  
Old August 24th, 2005, 01:15 PM
Alvaro G Vicario
Guest
 
Posts: n/a
Default Re: Postponing execution time out

*** alex wrote/escribió (Tue, 23 Aug 2005 14:45:46 +0200):[color=blue]
> 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.[/color]

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
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles