On a long running system I usually have a terminal with

$ tail -f /var/log/kern.log

or something like this open.

But from time to time I have to restart such command because no new messages are displayed anymore.

I assume this is because of the log rotating job that has replaced the log file tail -f was 'watching'.

How can I avoid this restarting issues?

Can I invoke tail such that it notices the rotating process and does the right thing?

(I notice this issue on a Ubuntu 11.04 system that uses rsyslogd by default.)


1 Answer 1


Use the -F option instead:

tail -F /var/log/kern.log

The -F option tells tail to track changes to the file by filename, instead of using the inode number which changes during rotation. It will also keep trying to open the file if it's not present.

  • 7
    Awesome, yes, I am. (just for the record, this is a GNU tail option - where GNU tail is of course the default on Ubuntu). Oct 16, 2011 at 15:51
  • You are right :-/ I did not noticed that Ubuntu in your question was only an example.
    – andcoz
    Oct 16, 2011 at 17:08
  • not a problem at all - I just commented for completeness (sometimes I just want to look what is POSIX and what is not). The question was indeed pretty much about Ubuntu. Oct 16, 2011 at 18:22
  • 3
    Is tail -F /var/log/kern.log equivalent to tail -f --follow=name --retry /var/log/kern.log?
    – Basj
    Sep 15, 2017 at 13:03
  • 4
    @Basj - according to man7.org/linux/man-pages/man1/tail.1.html it's equivalent
    – andrej
    Aug 9, 2018 at 17:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.