[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cobalt-users] RE: Re: Real time log monitoring scrip



Hi -

> <?php
> ini_set("max_execution_time",3000000);
> $filename = "/var/log/maillog";
>
> $file_size = filesize($filename);
>
> $fh = fopen($filename, 'r');
> $myOutput = fread($fh, $file_size);
> $myOutput = str_replace("\n", "<br>\n", $myOutput);
> # Uncomment this line, if you want to see previous
> # output as well.
> #print $myOutput;
>
> # I used $c for debugging ... just keeps it 1=1, for
> # a continuous loop.
> $c = 1;
> while ( $c == 1 )
> {
>         clearstatcache();
>         $tmpSize = filesize($filename);
>         if ( $tmpSize  <> $file_size )
>         {
>                 print "ok";
>                 $readBytes = $tmpSize - $file_size;
>                 $file_size = $tmpSize;
>                 $myOutput = fread($fh, $readBytes);
>                 print $myOutput;
>                 echo str_pad(" ", 256) . "<br>";
>                 flush();
>                 $c=1;
>         }
> }
> ?>

I created this script and set permissions to:

-rwxrwxrwx    1 httpd    httpd         695 Sep 25 09:56 logs.php

I get this in my access error logs:

[Thu Sep 25 09:57:43 2003] [error] PHP Warning:
fopen("/var/log/maillog", "r") - Permission denied in
/home/sites/home/users/admin/web/logs.php on line 7
[Thu Sep 25 09:57:43 2003] [error] PHP Warning:  Supplied
argument is not a valid File-Handle resource in
/home/sites/home/users/admin/web/logs.php on line 8

The firsat line seems to dislike the 'httpd' user and not sure
about the second line.... can you help. Thanks for the
contribution.

regards

Jon