我已经尝试了一个名为throw cronjobs的长脚本解决方案和超时问题(事实上我需要恢复大量数据并将其存储在数据库中,每天4次)。
所以我创建了一个php页面,使用fopen(),使用不同的vars多次调用相同的文件,以便接收文件选择\不同的数据部分并存储它们。
我使用fopen()就像文件的10倍。
以下是该脚本的一部分:
function call() {
$time_start_insert = microtime(true);
$server = "servername";
// *********** *********** OPEN PROCESSES lvl 1 ***********
echo "<div><br><i>************ Jobs Market Insert ************</i></div><br>";
echo "<br><div><i>************ Server $server lvl 1 ************</i></div><br>";
// *********** *********** OPEN PROCESSES lvl 1 ***********
// open child process
echo "<br><i><p class='start'>************ Lunched process 0-10 lvl 1 ************</i></p>";
$numC = "10";
$fromC = "0";
$workSkill = "1";
$fileName = urlencode("".ucfirst($server)." Job $fromC-$numC lvl $workSkill");
$url = "http://URL.../dbjob.php?server=$server&csel=$numC&cfn=$fromC&joblevel=$workSkill&fname=$fileName";
echo "<br>";
print_r($url);
$child1j10 = fopen($url, 'r') or die("<br>Couldn't get file, so I'll retry<br>".print_r($url)."<br>".fopen($url, 'r'));
echo_flush();
// Output one line until end-of-file
if($child1j10) {
$buffer = stream_get_contents($child1j10);
echo "<br>";
echo "<br><b><p class='titles'>++++++++++++++This is response from process:++++++++++++++++++</b></p>";
print_r($buffer);
echo "<br><b><p class='endtitles'>--------------FINISHED process called job 10 lvl 1 --------------</b><br></p>";
fclose($child1j10);
}
echo_flush();
// open child process
echo "<br><i><p class='start'>************ Lunched process 10-20 lvl 1 ************</i></p>";
$numC = "10";
$fromC = "10";
$workSkill = "1";
$fileName = urlencode("".ucfirst($server)." Job $fromC-".($fromC+$numC)." lvl $workSkill");
$url = "http://URL/dbjob.php?server=$server&csel=$numC&cfn=$fromC&joblevel=$workSkill&fname=$fileName";
echo "<br>";
print_r($url);
$child1j20 = fopen($url, 'r') or die("<br>Couldn't get file, so I'll retry<br>".print_r($url)."<br>".fopen($url, 'r'));
echo_flush();
// Output one line until end-of-file
if($child1j20) {
$buffer = stream_get_contents($child1j20);
echo "<br>";
echo "<br><b><p class='titles'>++++++++++++++This is response from process:++++++++++++++++++</b></p>";
print_r($buffer);
echo "<br><b><p class='endtitles'>--------------FINISHED process called job 20 lvl 1 --------------</b><br></p>";
fclose($child1j20);
}
//stream_set_timeout($child1j40, 2700);
echo_flush();
所以我推出了这个页面,它适用于ex。 6次,比回报我:
//from fist print_r
http://URL/dbjob/dbjob.php?server=primera&csel=10&cfn=60&joblevel=2&fname=Primera+Job+60-70+lvl+2
//from second print_r
http://URL/dbjob.php?server=primera&csel=10&cfn=60&joblevel=2&fname=Primera+Job+60-70+lvl+2
Couldn't get file, so I'll retry
1
Resource id #17
你知道为什么吗?
THX。