Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

1 Answer 1

up vote 46 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
5  
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

 
discard

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.