[olug] From Tejaswi: Unix Utils in Windows (fwd)
David Walker
olug at grax.com
Sun Feb 13 17:26:55 UTC 2005
The secret I use is to presume that the log file after logrotate will always
be smaller than the log file before logrotate. This should be true nearly
all of the time unless you have unusual log usage patterns.
To programmatically open the log file
Record the current_file size
If current_file_size is larger than previous_file_size
seek previous_file_size
else
seek 0;
end if
read until eof
To use tail instead of programmatically opening the log and seeking what you
need you would do
Record the current_file size
If current_file_size is larger than previous_file_size
tail -c (current_file_size - previous_file_size) FILENAME
else
cat FILENAME
end if
read until eof
but this method could result in a few lost characters if a write occurred
between reading the current file size and the tail command.
On Sunday 13 February 2005 10:44 am, Jon Larsen wrote:
> -------- Original Message --------
> Date: Fri, 11 Feb 2005 13:50:18 -0800 (PST)
> From: Tejaswi Manjunath <tejas at zoonic.com>
> Reply-To: tejas at zoonic.com
>
> ---------------------------------------------------------------------------
>-------
>
> Subject: tail in windows ?? need more options !!
> Body:
> i am trying to use tail command in windows, i downloaded the Win 2003
> Server Resource Kit and got hold of tail.exe, so it does take options of
> -c, -f, -q, -n, -v !!!
>
> my problem is i am looking for using the option of -r - as my program is
> supposed to read the updated contents of the file, and i am thinking of
> scanning the file backwards will get me to the point i want to stop
> reading easily and faster....keeping in mind log rotate that occours on
> log files....
>
> (i know there is another way of doing this also - keep track of the last
> scanned file, its size, last record, its size, and then do -> tail -c
> BYTES FILENAME, and get the required input only....but this will totally
> screw up cos of log rotate !!!)
>
> Any suggestions I would appreciate any help !!! Thanks guys
>
> by the way this is for a deamon of unix that could be installed on
> windows....
>
>
> ---------------------------------------------------------------------------
>------------------
More information about the OLUG
mailing list