PHP: Coding long-running scripts when servers impose an execution time limit
Posted
by thomasrutter
on Stack Overflow
See other posts from Stack Overflow
or by thomasrutter
Published on 2010-05-14T03:12:25Z
Indexed on
2010/05/14
3:14 UTC
Read the original article
Hit count: 350
FastCGI servers, for example, impose an execution time limit on PHP scripts which cannot be altered using set_time_limit()
in PHP. IIS does this too I believe.
I wrote an import script for a PHP application that works well under mod_php but fails under FastCGI (mod_fcgid) because the script is killed after a certain number of seconds. I don't yet know of a way of detecting what your time limit is in this case, and haven't decided how I'm going to get around it. Doing it in small chunks with redirects seems like one kludge, but how?
What techniques would you use when coding a long-running task such as an import or export task, where an individual PHP script may be terminated by the server after a certain number of seconds?
Please assume you're creating a portable script, so you don't necessarily know whether PHP will eventually be run under mod_php, FastCGI or IIS or whether a maximum execution time is enforced at the server level.
© Stack Overflow or respective owner