<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<br>
Joel Goguen wrote:
<blockquote cite="mid:1191191607.26806.5.camel@hermes" type="cite">
<pre wrap="">On Sun, 2007-09-30 at 17:04 -0500, Brian Fahrlander wrote:
</pre>
<blockquote type="cite">
<pre wrap="">While we've got the attention of the most-able on this subject, I'd
like to reopen a discussion about a very similar tool: a 'grep' that
happens on tailing a file. There have been dozens of times that I'm
looking for a message number in /var/log/mail.log and would love to see
only the lines mentioning that message.
A couple of years ago I asked and got a "maybe you could write
something", but I actually never could. It's not as easy as it looks.
Any chance you guys have seen this done</pre>
</blockquote>
<pre wrap=""><!---->I have a great deal of success with 'tail -f /var/log/mail.log | grep
XX' where XX is whatever you're looking for. I actually use that exact
set of commands on a daily basis when I'm at work.
</pre>
</blockquote>
<br>
The magical part here is the "-f"... unfortunately, sometimes it's not
magical enough. Indeed your mail.log is most likely a rolling log (i.e.
when it reaches a certain size, the current mail.log is renamed to *.0,
while the last *.0 is renamed *.1, the last *.1 is renamed *.2 and so
on for the number of instances to be kept - for the /var/log/maillog
it's 6, if I remember well).<br>
<br>
So the problem is when your file gets renamed *.0 that the "tail -f"
will stop because tail refers the file by the inode which doesn't
change when it is renamed... and when the renaming occurs, tail -f
keeps watching the old file (now called *.0 and not being appendend
anymore).<br>
<br>
What you want is for "tail -f" to keep looking, every now and then, say
every 5 seconds, to see if the file it was watching hasn't been moved
and a new file with the same name is being populated instead...<br>
<br>
There is a flag for "tail" to do just that.<br>
<br>
Try "tail -F" (UPPERCASE "F" instead of lowercase "f")... :)<br>
<br>
Have fun with your newly discovered "tail -F /var/log/mail.log".<br>
<br>
Gilles.<br>
<br>
<div class="moz-signature">-- <br>
<meta content="text/html; " http-equiv="content-type">
<title>Signature Home Chastity</title>
<meta content="Gilles Gravier" name="author">
<span style="color: rgb(0, 0, 0);"></span>
<div style="text-align: left;">
<table
style="text-align: left; background-color: rgb(102, 102, 102); width: 500px; height: 73px;"
border="1" cellpadding="3" cellspacing="3">
<tbody>
<tr>
<td
style="text-align: center; vertical-align: middle; background-color: rgb(204, 204, 204); white-space: nowrap;">
<div
style="text-align: center; background-color: rgb(204, 204, 204);"><tt><font
color="#7d6eaf"><i><b>Gilles Gravier</b></i> <b>=</b> </font><a
href="mailto:Gilles@Gravier.org"><font color="#000000"><b>Gilles@Gravier.org</b></font></a><font
color="#7d6eaf"> <b>=</b> </font><a href="http://www.gravier.org/"><font
color="#000000"><b>http://www.gravier.org/</b></font></a></tt><br>
</div>
<div
style="text-align: center; background-color: rgb(204, 204, 204);"><tt><font
color="#009900"><span
style="font-family: monospace; color: rgb(0, 0, 0); font-weight: bold;"></span></font><font
color="#000099">ICQ :</font> <a
href="http://www.icq.com/whitepages/about_me.php?Uin=77488526"><font
color="#009900"><b>77488526</b></font></a></tt> <tt><font
color="#009900"><b><span
style="font-family: monospace; color: rgb(0, 0, 0);"> || </span></b></font></tt><tt><font
color="#000099">MSN Messenger : <a
href="http://members.msn.com/Gilles@Gravier.org"><span
style="color: rgb(0, 153, 0); font-weight: bold;">Gilles@Gravier.org</span></a></font></tt><tt><font
color="#009900"><b><span
style="font-family: monospace; color: rgb(0, 0, 0);"><br>
</span></b></font></tt><span
style="font-family: monospace; color: rgb(0, 0, 153);">Skype</span><tt><font
color="#000099"><span style="color: rgb(0, 0, 153);"> : </span><a
href="callto://ggravier"><span
style="font-weight: bold; color: rgb(0, 153, 0);">ggravier</span></a></font></tt><tt><font
color="#009900"><b><span
style="font-family: monospace; color: rgb(0, 0, 0);"> || </span></b></font></tt><tt><font
color="#000099"><span style="color: rgb(0, 153, 0);"></span><span
style="font-weight: bold;"></span>Y! : <a
href="http://profiles.yahoo.com/ggravier"><span
style="color: rgb(0, 153, 0); font-weight: bold;">ggravier</span></a></font></tt><tt
style="font-weight: bold;"><font color="#009900"><span
style="font-family: monospace; color: rgb(0, 0, 0);"> || </span></font></tt><tt><font
color="#000099">AOL : <a href="aim:goim?screenname=gillesgravier"><span
style="color: rgb(0, 153, 0); font-weight: bold;">gillesgravier</span></a><br>
</font></tt><tt><font color="#000099">PGP Key ID :</font> <a
href="http://pgp.mit.edu:11371/pks/lookup?search=0x8DE6D026&op=index"><font
color="#009900"><b>0x8DE6D026</b></font></a></tt><br>
</div>
<div
style="text-align: center; background-color: rgb(204, 204, 204);"><tt><a
style="font-weight: bold; color: rgb(0, 153, 0);"
href="http://www.gmap-track.com/user.php?user=ggravier">My Last Known
Position / Ma Derniere Position Connue</a><br>
"Chastity
is its own punishment." (<font color="#999999"><i>Solomon Short</i></font>)
[<font color="#666666"><i>David Gerrold</i></font>]<br>
</tt><span style="font-family: monospace;">"De toutes les
aberrations sexuelles, la chasteté est la plus aberrante." [<span
style="font-style: italic;"><font color="#666666">Anatole France</font></span>]</span><br>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>