🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.admin
6 messages
6 total messages Started by Vince Thu, 01 Mar 2001 22:04
tail -f and log file rotation
#4066
Author: Vince
Date: Thu, 01 Mar 2001 22:04
15 lines
1740 bytes
I suppose I'm not the only one to have the following problem:

I use "tail -f" to get the new entries in the syslog file. But when the file
is renamed  (because it's too big or too old), tail is stuck on the renamed
file, which is not appended anymore.
I've heard about "tailf" (linux) or the option "tail -fname", but there is
nothing like that on Solaris, HP-UX or AIX.

Where can I get some source code to build my own tail that will support this
option or will follow and returned the entries inserted in the new syslog
file?

Thanks for your help.

Vincent
Re: tail -f and log file rotation
#4067
Author: Barry Margolin
Date: Thu, 01 Mar 2001 22:09
23 lines
2596 bytes
In article <t9thrboar8bh8e@corp.supernews.com>,
Vince <vlasfargues@yahoo.com> wrote:
>I suppose I'm not the only one to have the following problem:
>
>I use "tail -f" to get the new entries in the syslog file. But when the file
>is renamed  (because it's too big or too old), tail is stuck on the renamed
>file, which is not appended anymore.
>I've heard about "tailf" (linux) or the option "tail -fname", but there is
>nothing like that on Solaris, HP-UX or AIX.
>
>Where can I get some source code to build my own tail that will support this
>option or will follow and returned the entries inserted in the new syslog
>file?

Practically all Linux utilities come from GNU.  So if Linux has tailf, you
can probably find it in the GNU fileutils, which should port to most
versions of Unix.

-- 
Barry Margolin, barmar@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
Re: tail -f and log file rotation
#4068
Author: Nate Eldredge
Date: Fri, 02 Mar 2001 00:29
21 lines
2211 bytes
"Vince" <vlasfargues@yahoo.com> writes:

> I suppose I'm not the only one to have the following problem:
> 
> I use "tail -f" to get the new entries in the syslog file. But when the file
> is renamed  (because it's too big or too old), tail is stuck on the renamed
> file, which is not appended anymore.
> I've heard about "tailf" (linux) or the option "tail -fname", but there is
> nothing like that on Solaris, HP-UX or AIX.
> 
> Where can I get some source code to build my own tail that will support this
> option or will follow and returned the entries inserted in the new syslog
> file?

Get GNU tail (from the Textutils at ftp.gnu.org) and use the
--follow=filename option.

-- 

Nate Eldredge
neldredge@hmc.edu
Re: tail -f and log file rotation
#4069
Author: Cyrille Lefevre
Date: Fri, 02 Mar 2001 03:25
67 lines
3659 bytes
Nate Eldredge <neldredge@hmc.edu> writes:

> "Vince" <vlasfargues@yahoo.com> writes:
> 
> > I suppose I'm not the only one to have the following problem:
> > 
> > I use "tail -f" to get the new entries in the syslog file. But when the file
> > is renamed  (because it's too big or too old), tail is stuck on the renamed
> > file, which is not appended anymore.


> > I've heard about "tailf" (linux) or the option "tail -fname", but there is
> > nothing like that on Solaris, HP-UX or AIX.

tail -f exists under all flavors of unices but doesn't work on renamed file.
BSD flavors have tail -F which handle this case.

> > Where can I get some source code to build my own tail that will support this
> > option or will follow and returned the entries inserted in the new syslog
> > file?

ftp://ftp.freebsd.org/pub/FreeBSD/branches/-current/src/usr.bin/tail/

BSD tail -F can be easily simulated this way:

#!/bin/sh
trap '[ -n "$pid" ] && kill $pid' 2 3 15
file=$1 tmout=60
while sleep $tmout; do
        [ -f "$file" ] || continue
        new=`ls -i "$file" 2>/dev/null | awk '{print $1}'`
        if [ "$old" != "$new" ]; then
                old=$new
                [ -n "$pid" ] && kill $pid
                tail -f "$file" & pid=$!
        fi
done

> Get GNU tail (from the Textutils at ftp.gnu.org) and use the
> --follow=filename option.

GNU tail -f doesn't work on renamed or removed files. try this and see:

ls >> /tmp/log
gtail -f log &
ls >> /tmp/log
(ok)
mv /tmp/log /tmp/olog
ls >> /tmp/log
(nothing)
rm /tmp/olog
ls >> /tmp/log
(nothing)

the lesson is... GNU tools aren't good everywhere :)

PS : Vince, when you crosspost, don't forget to put a followup-to.
also, don't crosspost on groups w/ different languages as you do (fr).

fu2 cua

Cyrille.
-- 
home: mailto:clefevre%no-spam@poboxes.com.invalid    | UNIX is user-friendly;
work: mailto:Cyrille.Lefevre%no-spam@edf.fr.invalid  | it's just particular
Supprimer "%no-spam" et ".invalid" pour me repondre. | about who it chooses
Remove "%no-spam" and ".invalid" to answer me back.  | to be friends with.
Re: tail -f and log file rotation
#4070
Author: Paul Sack
Date: Fri, 02 Mar 2001 06:00
20 lines
2301 bytes
In article <t9thrboar8bh8e@corp.supernews.com>, Vince wrote:
>I suppose I'm not the only one to have the following problem:
>
>I use "tail -f" to get the new entries in the syslog file. But when the file
>is renamed  (because it's too big or too old), tail is stuck on the renamed
>file, which is not appended anymore.
>I've heard about "tailf" (linux) or the option "tail -fname", but there is
>nothing like that on Solaris, HP-UX or AIX.

Another thing you can do is tell logrotate[0] to copy the log file to its new
place, then truncate the log file. i.e. cp messages to messages.1 and truncate
messages. Then everything will work.

There are opinions on whether or not this is a good thing. You *can* lose a few
messages between when the copy occurs and the file is truncated.

[0] I assume this is what you are using.

-- 
Schizophrenia beats being alone.
Re: tail -f and log file rotation
#4065
Author: Paul Sack
Date: Sat, 03 Mar 2001 03:00
20 lines
2220 bytes
In article <t9thrboar8bh8e@corp.supernews.com>, Vince wrote:
>I suppose I'm not the only one to have the following problem:
>
>I use "tail -f" to get the new entries in the syslog file. But when the file
>is renamed  (because it's too big or too old), tail is stuck on the renamed
>file, which is not appended anymore.
>I've heard about "tailf" (linux) or the option "tail -fname", but there is
>nothing like that on Solaris, HP-UX or AIX.
>
>Where can I get some source code to build my own tail that will support this
>option or will follow and returned the entries inserted in the new syslog
>file?

I had another idea that we used at $EMPLOYER[-1].

Make a named pipe. Add this named pipe to syslog.conf. Do ``tail -f'' with
named pipe.

-- 
The world is coming to an end.  Please log off.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads