Find the answer to your Linux question:
Results 1 to 4 of 4
Hello, I am running a script with nohup and this generates a lot of logs. In order to view the log I use tail -f nohup.out The problem is that ...
  1. #1
    Just Joined!
    Join Date
    Aug 2010
    Posts
    5

    tail command does not refresh all the time

    Hello,

    I am running a script with nohup and this generates a lot of logs.

    In order to view the log I use tail -f nohup.out

    The problem is that the info supplied by this command is not always the latest//sometimes I need to use the command again order to view the latest info added to the nohup.out file.

    Can you tell me if I am doing something wrong? or this is the way it normally works?

    I need to mention that I am using RedHat ES 5.0

    Thanks!

  2. #2
    Linux Newbie
    Join Date
    Dec 2009
    Posts
    241
    Hi,
    I've remmember that I had equal problems in the past with tail -f
    Well I didn't use it much and decided to ignore it.

    What I found, what may help you, is that tail -f will watch the file with the name at first.

    Lets say you use a script to move the log sometime and start a new one.
    tail -f will watch the moved file.

    You may wanna try:
    tail -F filename

    Detailed information:
    UNIX man pages : tail ()

  3. #3
    Just Joined!
    Join Date
    Aug 2010
    Posts
    5
    I do not move the nohup.out file. Simply the information it displayes is not the latest one. In order to see the latest one I have to enter the tail command again...

    Any ideeas why?

  4. #4
    Linux Guru Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    2,096
    zombykillah is right, and here is the reason:
    Apparently the filedescriptor for nohup.out gets deleted at some point.
    Which is why tail cannot follow any more.

    Then a new file nohup.out with a *new* filedescriptor gets created.

    And yes, tail -F will follow, even if the fd has been deleted.

    Just try it
    Code:
    tail -F /tmp/foo
    
    echo 1 > /tmp/foo
    rm -f   /tmp/foo
    echo 2 > /tmp/foo
    vs

    Code:
     touch  /tmp/bar
    tail -f /tmp/bar
    
    echo a > /tmp/bar
    rm -f /tmp/bar
    echo b > /tmp/bar
    Last edited by Irithori; 11-02-2010 at 01:47 PM. Reason: reordering of commands for clarity
    You must always face the curtain with a bow.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...