On Wed, May 6, 2009 at 11:15 PM, Brian McQueen <address@hidden> wrote:
> The new feature is demonstrated by a wrapper script around tail which
> gives me the ability to use tail to drive arbitrary alerts like this
> (only the core concept lines are shown):
>
>
>
> # put it into the background
>
> tail -n 0 -f error_file > working_file &
>
>
>
> #wait for some lines to arrive
>
> while ! test -s working_file
>
> do
>
>
>
> Â Â echo nothing yet... Â Going to sleep for:timeout:$timeout: >&2
>
> Â Â sleep $timeout
>
>
>
> done
>
>
>
> #got some lines so cat them
>
> cat working_file
>
>
>
> This allows me to watch a file for maybe 10 second intervals, and grab
> all lines that arrived during that time interval. Â If nothing arrived,
> then it keeps on waiting. Â This effectively allows me to drive shell
> scripts with stdin model, but only on when new lines arrive.
>
>
>
> It is used like this:
>
>
>
> ./recent_line_tail error_log | alarm_handler_script
>
>
>
> This functionality could be put into tail with a single new option.
> Proposed Usage (a for alert, or maybe n for new?):
>
>
>
> tail -a 23 error_log
>
>
>
> I propose this would check for output each 23 seconds, and if it finds
> any it will cat it and stop. Â If there are no lines then it would wait
> another 23 seconds.
Why not use something designed for the purpose of watching log files,
for example http://www.fourmilab.ch/webtools/logtail/ but ... ?
James.