tags:

views:

25

answers:

5

I want run a php script weekly using a cron job, however the script may take a few minutes or more.

Is there any way i can allow a greater max_execution_time just for this script?

A: 

set_time_limit

Alex L
A: 

You can use set_time_limit(). If you want to disable timeout overall, pass it 0 as an argument. Otherwise pass it the number of seconds of max execution time.

reko_t
A: 

You can use set_time_limit(0) at the start of your code: this removes the execution time limit altogether for this script. Note that it means that the script could run "forever", so put some checks in place in case it hangs.

Piskvor
+2  A: 

Maybe you should try these answers:

But of course, using ini_set("max_execution_time",60) as the first php line in your job's script should do the trick.

Regards, Daniel

dhh
+2  A: 

You don't need to set a higher max_execution_time if you use PHP CLI: http://nl3.php.net/manual/en/features.commandline.differences.php

Lekensteyn