// exec('mongoexport -h 192.168.6.97 --port 40000 -d fenjianlidb -c fenjianli -f "meta_info.file_path" -q "{\'create_time\':{\'$gte\': \'1487088000\',\'$lte\': \'1487644200\'}}" -o ' . $save_path .'middle.txt', $ret); //window平臺
成都創(chuàng)新互聯(lián)公司IDC提供業(yè)務(wù):服務(wù)器托管機柜,成都服務(wù)器租用,服務(wù)器托管機柜,重慶服務(wù)器租用等四川省內(nèi)主機托管與主機租用業(yè)務(wù);數(shù)據(jù)中心含:雙線機房,BGP機房,電信機房,移動機房,聯(lián)通機房。
//php 執(zhí)行
exec('mongoexport -h 192.168.6.97 --port 40000 -d zhengliangdb -c newzengliang -f "meta_info.file_path" -q \'{create_time:{$gte: 1487645408,$lte: 1487646251}}\' -o /data/work_time/work0221/testMid/middle.txt', $ret); //Linux 成功 (切記轉(zhuǎn)移) mongoexport --help 查看
--------------------------------------測試代碼-----------------------------------------
/**
* @Author: lixiaozhu
* @Date: 2016-09-21 12:51:55
* @Last Modified by: lixiaozhu
* @Last Modified time: 2017-01-20 18:50:24
*/
set_time_limit(0);
// $save_path = 'D:/phpStudy/WWW/test01/mongo/test0221/';
$save_path = '/data/work_time/work0221/testMid/';
//中間件
// exec('mongoexport -h 192.168.6.97 --port 40000 -d fenjianlidb -c fenjianli -f "meta_info.file_path" -q "{\'create_time\':{\'$gte\': \'1487088000\',\'$lte\': \'1487644200\'}}" -o ' . $save_path .'middle.txt', $ret); //window平臺
//php 執(zhí)行
exec('mongoexport -h 192.168.6.97 --port 40000 -d zhengliangdb -c newzengliang -f "meta_info.file_path" -q \'{create_time:{$gte: 1487645408,$lte: 1487646251}}\' -o /data/work_time/work0221/testMid/middle.txt', $ret); //Linux 成功
$groups = array(
'group1' => 'http://192.168.6.49/',
'group2' => 'http://192.168.6.50/',
);
$content = file_get_contents($save_path . 'middle.txt');
$list = preg_split('/\s+/', $content);
$prefix = date('YmdH');
foreach ($list as $key => $item) {
echo $key++, PHP_EOL;
$item = json_decode($item, true);
$file_path = trim($item['meta_info']['file_path']);
$group = substr($file_path, 0, 6);
if (isset($groups[$group])) {
$url = $groups[$group] . $file_path;
$content = file_get_contents($url);
if(false !== strpos($content,'zhaopin.com')){ //可能會有 zhaopin.cn localhost/qiaoda/zhilian/z1.html
error_log($url . PHP_EOL, 3, $save_path . $prefix .'_zhilian.txt');
} elseif (false !== strpos($content,'51job.com')){
error_log($url . PHP_EOL, 3, $save_path . $prefix .'_51job.txt');
} elseif (false !== strpos($content,'liepin.com')){
error_log($url . PHP_EOL, 3, $save_path . $prefix .'_liepin.txt');
} elseif (false !== strpos($content,'ganji.com')){
error_log($url . PHP_EOL, 3, $save_path . $prefix . '_ganji.txt');
} elseif (false !== strpos($content, '58.com')){
error_log($url . PHP_EOL, 3, $save_path . $prefix . '_58tongchen.txt');
} elseif (false !== strpos($content, 'chinahr.com')){
error_log($url . PHP_EOL, 3, $save_path . $prefix . '_YCjianli.txt');
} else {
error_log($url . PHP_EOL, 3, $save_path . $prefix . '_other.txt');
}
} else {
echo 'mubanFileError';
error_log($file_path . PHP_EOL, 3, $save_path . $prefix . '_mubanFileError.txt');
}
unset($content);
}