I want to write a php script that keeps the apache_log file open and listens for the log and processes each log entry when this happens.
I think I need to open the file, get the number of lines, and then do it again in a loop - and when the size is different, read the new lines and process them.
Am I sneaking up on the wrong tree, or is there a silly simple solution I missed?
Chris
A quick-dirty way would be to use it somehow tail -f(if available):
tail -f
PHP: tail -f file | php myscript.php, php://stdin.
tail -f file | php myscript.php
php://stdin
popen script:
popen
$res = popen('tail -f file_name', 'r'); while (!feof($res)) { $line = fgets($res); echo $line; }
php inotify, , , . eralier , , .
The option that comes to my mind will run the script from the cron job every minute or so and just remember the last line that you were in every moment.
Source: https://habr.com/ru/post/1738072/More articles:What is the easiest way to get the built-in progress bar with Ruby / Sinatra / Haml / Passenger / nginx? - progress-barcan iis 7 be used to manage users when using authentication with asp.net - asp.netNginx update download module with rails and passenger - ruby-on-railsManaging users in Silverlight, creating a user interface, or using the ASP.NET website administration tool? - asp.netC # - Running Exe without using System.Diagnostics.Process.Start - c #Как управлять пользователями ASP.Net на сервере без разработки? - asp.netКак мне начать открытие ссылки href в диалоговом окне jQuery? - jqueryHow to filter the models that I see in the Add View dialog using ASP.NET MVC? - asp.net-mvcsymfony 1.4 adds BCC recipient for mailer - swiftmailerProgrammatically adjust shadow properties in PowerPoint - vbaAll Articles