Skip to content

Instantly share code, notes, and snippets.

@deizel
deizel / tail.php
Created October 6, 2012 22:08
PHP log tail example
<?php
if (isset($_GET['ajax'])) {
session_start();
$handle = fopen('/private/var/log/system.log', 'r');
if (isset($_SESSION['offset'])) {
$data = stream_get_contents($handle, -1, $_SESSION['offset']);
echo nl2br($data);
} else {
fseek($handle, 0, SEEK_END);
$_SESSION['offset'] = ftell($handle);