开发者

is there any limit to how much time the server can process?

I have the following file which process a single XML file and pushes it into the Database as a row. It works perfectly for single files.

Now i wanted to put ALL files in the directory like this into the database and hence wrote a script to go over the directory and push all the files in it one by one. And YES it did work, but it stopped after processing XX (variable) amount of files

I though may be something wrong with my XML file, so decided to just have SINGLE XML file (which was perfectly processed earlier) in the directory and just loop over it, inserting it hundreds of time, so that i could confirm its a problem with my files. But guess what happened?

After processing XX(variable) amount of files, the processing stops. In my below example, it stopped at 110 (counter val), 111, 99 etc after repeated attempts. Where it should have processed 1000 files.

<?php
include_once '../includeTop.php';

header ( 'Content-type: text/xml' );

echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
$dir = "../../newHotelFiles";
$file = NULL;
$fileName = "noFileName";

$processed = 0;
util::writeToLog ( $dir . '/progressData.tmp', "Files processed: $processed" );
try {

    echo XMLInterface::openTag ( "start" );
    for($counter = 0; $counter < 1000; $counter ++) {
        $dirHandle = opendir ( '../../newHotelFiles' );
        while ( false !== ($file = readdir ( $dirHandle )) ) {
            //process my files codes

                $processed ++;
                util::writeToLog ( $dir . '/progressData.tmp', "Files processed: $processed" );


            }

        }

    //util::writeToLog($dir.'/progressData.tmp', "Done ".$counter);
    }
    echo XMLInterface::closeTag ( "start" );
    exit ();
} catch ( Exception $e ) {
    echo XMLInterface::failure ( "Error occured. Written to the log file - $file.log" );
    util::writeToLog ( "../../newHotelFile开发者_StackOverflows/$fileName.log", ExceptionHandler::error_msg ( $e ) );
    exit ();
}

?>

What is the problem? Is it the script (which i doubt as it works when the for loop is not there) or is there any serverside limit i donot know about


there is a max execution time limit in php called set_time_limit(); (along others)

        set_time_limit(0); // sets to unlimited


The script may be aborting because of a time limit. Try modifying the set_time_limit.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜