Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP backup script timing out

Tags:

php

backup

I have a backup script which backups up all files for a website to a zip file (using a script similar to the answer to this question). However, for large sites the script times out before it can complete.

Is there any way I can extend the length of time available for the script to run? The websites run on shared Windows servers, so I don't have access to the php.ini file.

like image 761
whostolemyhat Avatar asked May 10 '11 08:05

whostolemyhat


2 Answers

If you are in a shared server environment, and you don’t have access to the php.ini file, or you want to set php parameters on a per-site basis, you can use the .htaccess file (when running on an Apache webserver).

For instance, in order to change the max_execution_time value, all you need to do is edit .htaccess (located in the root of your website, usually accesible by FTP), and add this line:

php_value max_execution_time 300

where 300 is the number of seconds you wish to set the maximum execution time for a php script.

There is also another way by using ini_set function in the php file

eg. TO set execution time as 5 second, you can use

ini_set('max_execution_time', 300); //300 seconds = 5 minutes

Please let me know if you need any more clarification.

like image 176
Deepu S Nath Avatar answered Sep 20 '22 08:09

Deepu S Nath


set time limit comes to mind, but may still be limited by php.ini settings

set_time_limit(0);

http://php.net/manual/en/function.set-time-limit.php

like image 43
bumperbox Avatar answered Sep 21 '22 08:09

bumperbox