您的位置:首页 > 编程语言 > PHP开发

php读取LOG文件前N行。根据文件关键字,读取文件夹下最新的文件

2016-10-25 09:24 134 查看
if($id == 3){
$name="/tmp/youtube_upload.log";
$file = escapeshellarg($name);
$info = `tail -n 500 $file`;
}else if($id == 1){
chdir(LOGFILE);
$name=`ls -t |grep 'success_' | head -n1`;
$path=str_replace(PHP_EOL, '', $name);
$path=LOGFILE.$path;
$info="logファイル名:$path\n".file_get_contents($path);
}else if($id == 2){
chdir(LOGFILE);
$name=`ls -t |grep 'failure_' | head -n1`;
$path=str_replace(PHP_EOL, '', $name);
$path=LOGFILE.$path;
$info="logファイル名:$path\n".file_get_contents($path);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  php LOG 读取