Location: PHPKode > scripts > TailFile > tailfile/tail-example.php
#!/usr/bin/php -q
<?
# ----------------------------------------------
# Program     : tail-example.php
# Version     : 1.0
# Author      : Matthew Frederico
# Date        : March 21 2002
# ----------------------------------------------

/****************************/
/* Configuration parameters */
/****************************/
# File Locations

$tailfile               = "/var/log/maillog";

# How long to delay between checks on the log
# file updates

$check_delay    = 5;

/**********************************************/
/*          M A I N   P R O G R A M           */
/**********************************************/
include("tailfile.phpc");       // PHP Tail class.

// This is where we watch our mail log for updates
//---------------------------------------------
$t = new TailFile($tailfile);
print "Watching mail log... \n";

while ($t->isOpen())
{
        $t->checkUpdates();
        $myres = $t->getResults();

        if ($myres)
                print $myres;
        
        $t->wait($check_delay);
}
//---------------------------------------------
Return current item: TailFile