Actually, my advice would be to get a copy of swatch and start with it. This is probably the most common solution to the problem of watching log files. It is an optional package on most Linux distributions. If it doesn't do everything you want, it is written in Perl, so you can just edit it. Note that it solves several problems besides the ones that you mention, like playing well with logrotate when it truncates the log files.

Out of the box, it doesn't have the ability to monitor more than one log file at once. You could run a copy of swatch for each file, each with its own output window. Or, you could hack the source of swatch to allow multiple input files. Or, try this: create a named pipe with mkfifo, run one copy of tail -f for each input file, all sending their output to the pipe, and have swatch read the pipe as its input.

Whatever you do, don't allow your monitoring process to open a new window every two minutes without closing any of the previous ones automatically. If the graveyard shift operator catches the flu and the system is left unattended for many hours, you will have hundreds of copies of both less and xterm running. Depending on the system configuration, you might risk having the system run short of memory and do Bad Things.


In reply to Re: Log watcher which outputs alerts in xterm windows by quester
in thread Log watcher which outputs alerts in xterm windows by wishartz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.