Home > php教程 > php手册 > Tail for php,php实现tail命令

Tail for php,php实现tail命令

WBOY
Release: 2016-06-06 19:39:29
Original
1411 people have browsed it

监控文件变化,可以通过tail,inotify来实现,也可以通过awk转发变化的内容到外部命令中。 下面是通过popen来调用系统命令,性能内存开销相对比较

监控文件变化,可以通过tail,inotify来实现,也可以通过awk转发变化的内容到外部命令中。

下面是通过popen来调用系统命令,性能内存开销相对比较小。(转)

$handle = popen("tail -f /var/log/your_file.log 2>&1", 'r');
while(!feof($handle)) {
$buffer = fgets($handle);
echo "$buffer\n";
flush();
}
pclose($handle);
Copy after login

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template