Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.)

share|improve this question
up vote 70 down vote accepted

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.

share|improve this answer
Awesome, yes, I am. (just for the record, this is a GNU tail option - where GNU tail is of course the default on Ubuntu). – maxschlepzig Oct 16 '11 at 15:51
You are right :-/ I did not noticed that Ubuntu in your question was only an example. – andcoz Oct 16 '11 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. – maxschlepzig Oct 16 '11 at 18:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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