Solved

How to Tail a file that rolls over

Posted on 2002-05-31
3
451 Views
Last Modified: 2010-04-21
I have a file "a.log" that when it gets to 1MB, renames to "a.log.1"  The new files is created to continue loggin called "a.log".

I want to send the out put of "a.log" to a log file on a nfs mounted directory in real time.  The "tail -f" command will work up until the file reaches 1MB and renames itself.  The "tail" command stops working at this point.

How can I get it to ouput the files contents after the 1MB limit is reached?

Thanx
0
Comment
Question by:RudePuppyDog
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 6

Accepted Solution

by:
bira earned 100 total points
ID: 7047939
Hi
   Instead of "tail -f" , use a script like this:

    while true
    do
    tail -50 a.log
    done

  So, even when the a.log reaches 1MB and is renamed,
  it will go on showing the last 50 lines of the new one.
0
 
LVL 1

Expert Comment

by:tekweni
ID: 7048452
I dont have access to a unix box right now, but something like this may be worth putting into a script..

#!/bin/sh
while (1)
do
    tail -50 a.log.1 > /tmp/junkfile
    tail -50 a.log >> /tmp/junkfile
    cat /tmp/junkfile
    sleep 2
done

It almost certainly needs debugging, but the goal is to show you the last 50 entries regardless of the rollover between files.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7049818
get GNU version of tail, and use

  tail --retry -f a.log
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
pauing printer deamon in AIX 10 66
Vmware Vswitch  VS  Redhat  Bridge 1 120
MarkLogic 1 100
Access_log 17 164
Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question