Does Apache set a max execution time of its own?

12,624

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

https://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html

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.

Share:
12,624

Related videos on Youtube

xbonez
Author by

xbonez

I have a keen interest in the Language Development stack (Parsers, Lexers, ASTs, Compilers and VMs), Web development and Javascript frameworks (particularly AngularJS) along with security and cryptography. Lately been working on infrastructure and service monitoring, containers and Kubernetes.

Updated on September 18, 2022

Comments

  • xbonez
    xbonez almost 2 years

    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?

  • xbonez
    xbonez over 12 years
    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
    xbonez over 12 years
    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.
  • Brett Dikeman
    Brett Dikeman over 12 years
    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!
  • Brett Dikeman
    Brett Dikeman over 12 years