[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: tailing rotating log files



-----BEGIN PGP SIGNED MESSAGE-----

On Sun, 19 Sep 1999, Jim B wrote:

> Hi, I generallly keep some of my log files open ni a terminal via tail -f.
> For example:
> tail -f /var/log/messages
> 
> However, tail does not "move" to the new "messages" (or whatever) log file
> when they are rotated by savelog.  So for example, I will still see the last
> lines from the old messages file and I will have to terminate tail and run
> it again to force it to move to the new messages file.
> 
> If the file is moved and a new one put in its place, I'd like to start
> reading the new file.  I don't see any way to do this with tail (I checked
> in the man/info pages).  Is there a program which will do this?

At least with the tail in potato (tail (GNU textutils) 2.0), there is an
option to do this. The default option of tail with the -f option is to
open the file and follow that file descriptor. If you use "--follow=name"
instead of -f, it will periodically reopen the file to check if the file
was moved.

For example, i executed the following commands while tailing the file.
  $ echo "line 1" >> tail.test 
  $ echo "line 2" >> tail.test 
  $ mv tail.test tail.test.1; echo "line 3" >> tail.test

Here's the tail output:
  $ tail --follow=name tail.test
  line 1
  line 2
  tail: `tail.test' has been replaced;  following end of new file
  line 3



- -- 
  finger for PGP public key.

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3ia
Charset: noconv

iQCVAwUBN+UeH77M/9WKZLW5AQHenAQAlMhGO9VIX9WVlKmetyVmRm6Zrjkg5klx
i2PT/FjZ0aOxR7q71xLPEA4Yu/lron1PSC1S6aiPE02QHZOPY+Pekz847px91BKj
aS7C6LZ9nyWydd5WKnStjLMim6WJPtjhH7oBAzK9tp7cGYzRGrG4jWBfmF1iOXOz
ZQlRtNnD6zg=
=pYka
-----END PGP SIGNATURE-----


Reply to: