PHP日志解析器(读取文本文件)
我有一个日志文件,假设它是任何文本(txt)文件。
我正在使用 php 阅读它并执行功能。
与普通日志文件一样,日志文件几乎每 10 秒由程序更新一次,但时间间隔不固定。我准备延迟展示结果。
一种方法是使用 cron 作业(每 10-20 秒刷新一次脚本看起来相当奇怪)。
假设日志文件和 php 文件在同一台服务器上
我有自己的专用服务器 Ubuntu
谁能告诉我一种读取文件的方法?
每当文件更改时,诸如 php 文件之类的东西就会被执行,或者我是否必须使用 python/java 或其他语言来执行它?
如果答案仍然是 cronjobs,我该如何将它们添加到我的 Ubuntu 服务器中(我有 php 作为 apache 模块)?
谢谢
I have a log file assume it to be any text(txt) file.
I am reading it using php and performing functions.
The log file gets updated mostly every 10 seconds by a program as a normal log file does though the time interval is not fixed. I am ready to take some delay in showing the results.
One method is using cron jobs (which looks quite and odd to refresh the script every 10-20 seconds).
Assume the log file and the php file on the same server
I have my own dedicated server Ubuntu
Can anyone tell me a method through which i can read the file ?
Something like the php file gets executed whenever the file changes or do i have to use python/java or some other language for it ??
If the answer still sticks to cronjobs how do i add them in my Ubuntu server(i have php as a apache module) ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用:
或在命令行上命名日志文件的任何名称。这将使最后几行显示在终端中。您还可以指定要显示的行数,例如
You can use:
or whatever the log file is named on the command line. This will keep the last few lines displayed in the terminal. You can also specify how many lines to display, like