|
-
September 22nd, 2004, 11:35 PM
#1
Need longer timeouts in PHP
Hi all,
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
#2
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
#3
Do you know what the option is called? It currently is set as:
Code:
#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300
but it times out way before 5 min.
-
September 23rd, 2004, 12:05 AM
#4
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
#5
Nope, what I have of the script is posted below:
Code:
<?php
header("Content-type: text/html");
echo "<PRE>";
echo find_os();
echo find_browser();
echo whois_info();
echo netbios_info();
echo nmap_info();
function whois_info( )
{
$results =shell_exec("whois ".$_SERVER['REMOTE_ADDR']);
return $results;
}
function netbios_info( )
{
$results =shell_exec("nmblookup -A ".$_SERVER['REMOTE_ADDR']);
return $results;
}
function nmap_info( )
{
$results =shell_exec("nmap -sS -O -P0 -A -T insane ".$_SERVER['REMOTE_ADDR']);
return $results;
}
function find_os()
{
$browserarray=explode("; ",$_SERVER['HTTP_USER_AGENT']);
$os= $browserarray[2];
return $os;
}
function find_browser()
{
$browserarray=explode("; ",$_SERVER['HTTP_USER_AGENT']);
if ($browserarray[1]=="U"){
$browser = $browserarray[4];
}else {
$browser = $browserarray[1];
}
return $browser;
}
?>
By the way, thanks foir the help.
-
September 23rd, 2004, 12:39 AM
#6
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
#7
I did the changes, and it still times out in about 20 sec or so.
-
September 23rd, 2004, 12:49 AM
#8
Does it also timeout early with something like this:
Code:
<?php
$i = 1;
while ($i > 0)
{
echo($i . ' ');
$i++;
}
?>
-
September 23rd, 2004, 12:54 AM
#9
Nope, it just keeps going an going.
-
September 23rd, 2004, 01:03 AM
#10
Then I think it's because you're using shell_exec(). This is what php.net says about it here:
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.
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().
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|