Skip to content

Instantly share code, notes, and snippets.

@jakubboucek
Created February 7, 2020 01:55
Show Gist options
  • Save jakubboucek/49e6abc4990fe32d579475c964840e30 to your computer and use it in GitHub Desktop.
Save jakubboucek/49e6abc4990fe32d579475c964840e30 to your computer and use it in GitHub Desktop.
Php real file monitoring
<?php
declare(ticks=1);
$file = __DIR__ . '/scratch.log';
$f = popen(sprintf('tail -n 0 -f %s', escapeshellarg($file)), 'rb');
while (feof($f) === false) {
$buffer = fgets($f);
echo "Line: $buffer";
usleep(1000);
}
fclose($f);
echo "End\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment