I need to run a PHP script on my shared Linux hosting (LAMP). I estimate the script to take about an hour to execute.

in the PHP .ini file, I have set

max_execution_time = -1

So PHP will let the script run as long as it needs to.

But apart from PHP, does Apache set its own time limitation on execution of scripts, and if yes, can I change it in a shared hosting?

1 Answer 1


mod_fcgi (which is likely what your hosting company is using) supports a number of timeout parameters:


You should consult with your hosting company to find out how they've configured mod_fcgi timeouts; open a support ticket with them to ask, particularly since they may automatically kill long-running scripts. I think it's unlikely they'll allow a PHP script to run that long in a shared hosting environment.

Also, if the browser's connection is left idle for too long, the connection might be dropped by your router or the router at your hosting provider. You could work around this by having your PHP script output a single character, such as a "." every so often.

  • I'm not worried about the browser dropping the connection since once the request is made to the page and the execution begins, it continues even if the window/tab is closed. I was able to test this by monitoring the database the script keeps dumping data into
    – xbonez
    Jan 11, 2012 at 8:12
  • However, thanks for the tip on mod_fcgi. I'll check with my provider, GoDaddy
    – xbonez
    Jan 11, 2012 at 8:12
  • Also, what if I run the php script from command line? I belive, in that case, Apache and its settings never kick in since the execution is controlled entirely by php-cgi and not the web server.
    – xbonez
    Jan 11, 2012 at 8:31
  • Yes, Apache is not involved with the CLI php interpreter. If you run the script from the command line, you should not be using php-cgi. Just use "php"; you can use the -v option to get the version string, which should contain "(cli)". Glad my answer helped- would you 'accept' the answer so it is marked as answered? Thanks! Jan 12, 2012 at 4:47
  • 1
    php-cli.com/php-cli-cgi.shtml Jan 12, 2012 at 4:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.