Follow

Up ../

Follow — follow a file

A small program that tracks the contents of a log file by keeping the device, inode and offset of the end of the file in a state file. Mainly used from cron jobs.

Example - report on the proxy traffic since the last run

follow -o /squid/run/access.stat -f /squid/log/access.log | traffic_report

Source in files/

BUGS
If the log is rotated between the last run of follow and the next run, the lines from the end of the last run to the end of that log file are lost to follow - it just starts from the beginning of the new log file.

To fix this the program would need a strategy to locate the rotated file and check that file's inode number (and assuming it wasn't compressed.)

LICENSE
Creative Commons CC0 http://creativecommons.org/publicdomain/zero/1.0/legalcode

AUTHOR
James Sainsbury

SEE ALSO
MJR's retail program http://www.ranum.com/security/computer_security/code/retail.tar Although if the log file is being written faster than retail can read it I am not sure the process will exit before the log file is rotated.