开发者

Read file change in php (linux equivalent of tail -f )

I need to monitor the access.log of a website. I can use the unix tail -f in my php but the problem is that when the http server is restarted, the file is truncated and the read stops.

I need this featur开发者_JS百科e in php.


Haven't tried it, but maybe Inotify can help you:

inotify is a Linux kernel subsystem that acts to extend filesystems to notice changes to the filesystem, and report those changes to applications.

There's a php extension for inotify, see http://docs.php.net/manual/en/book.inotify.php


try using tail -F not -f -- this way it'll continue to monitor the file even if the file is truncated or deleted. it's not the best way though but saves the day.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜