September 22nd, 2004, 11:35 PM
Need longer timeouts in PHP
I'm working on a PHP script that takes a long time to run, I set up my PHP.ini with the following lines:
max_execution_time = 3000 ; Maximum execution time of each script, in seconds
max_input_time = 3000 ; Maximum amount of time each script may spend parsing request data
memory_limit = 208M ; Maximum amount of memory a script may consume (8MB)
I then restart Apache, but it still seems to time out well before the limit I set. Any ideas?
September 22nd, 2004, 11:46 PM
I think this is caused by Apache's timeout value in the httpd.conf file. Make sure it's more than or equal to the max_execution_time value in your php.ini file.
September 22nd, 2004, 11:56 PM
Do you know what the option is called? It currently is set as:
but it times out way before 5 min.
# Timeout: The number of seconds before receives and sends time out.
September 23rd, 2004, 12:05 AM
That's the option I'm talking about. Does the code use any sleep() functions or something similar, PHP's way of counting execution time is weird with that.
September 23rd, 2004, 12:09 AM
Nope, what I have of the script is posted below:
By the way, thanks foir the help.
function whois_info( )
$results =shell_exec("whois ".$_SERVER['REMOTE_ADDR']);
function netbios_info( )
$results =shell_exec("nmblookup -A ".$_SERVER['REMOTE_ADDR']);
function nmap_info( )
$results =shell_exec("nmap -sS -O -P0 -A -T insane ".$_SERVER['REMOTE_ADDR']);
$browser = $browserarray;
$browser = $browserarray;
September 23rd, 2004, 12:39 AM
PHP doesn't include the time spend on external programs (whois, nmblookup, and nmap in your case) when calculating the execution time. Setting the php.ini max_execution_time setting and the httpd.conf TimeOut directive to a high value should give you a lot of time to work with though. Let me know if it works or not.
September 23rd, 2004, 12:41 AM
I did the changes, and it still times out in about 20 sec or so.
September 23rd, 2004, 12:49 AM
Does it also timeout early with something like this:
$i = 1;
while ($i > 0)
echo($i . ' ');
September 23rd, 2004, 12:54 AM
Nope, it just keeps going an going.
September 23rd, 2004, 01:03 AM
Then I think it's because you're using shell_exec(). This is what php.net says about it here:
I'm afraid there's nothing that can be done about it. If you really want to do this, you could try writing PHP versions of the programs you're calling with shell_exec().
The set_time_limit() function and the configuration directive max_execution_time only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running.