Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Using the less command on linux in tail mode (F command or less -f) consistently stops working on certain machines and/or certain files. New changes simply stop showing up.

I know I've fixed this before, long ago, but I don't recall what the solution was.

Any ideas?

share|improve this question
    
Have you tried using strace to see what it's (not) doing? Maybe you'll see an error. –  wfaulk Oct 8 '09 at 15:39
    
FYI, this remains unanswered because the file in question was not being rolled/rotated/recreated. –  TREE Apr 26 '12 at 14:17
add comment

3 Answers

Try using less --follow-name. Even if the file has the same name, the process(es) updating it may be doing so in a way which changes the file's inode -- so from the OS point of view, it's a new file after the updates.

share|improve this answer
    
+1 perfect answer, that's just why this option was introduced. Note that --follow-name was introduced in less v415 (greenwoodsoftware.com/less/news.415.html ), released 15 Nov 2007. Thus old Linux installation may not have it. –  sleske Apr 29 '11 at 8:55
add comment

Are you viewing log files that are rotated by logrotate? If the file that less is viewing is renamed (e.g. from log to log.0 by logrotate), less will continue to watch that file, even though new entries are being written to a different file (with the original name).

share|improve this answer
    
If this is the case, try tail --follow=name [filename] (which causes tail to periodically reopen the file in case it is renamed). See gnu.org/software/coreutils/manual/html_node/… –  Randy Orrison Oct 8 '09 at 14:49
    
No, the logs are not rotating. It's the same file. –  TREE Oct 8 '09 at 15:14
add comment

maybe you could try tail -f [filename] instead?

share|improve this answer
4  
With less, you can "pause your tail" (by using Ctrl-c) to go up to a specific line and resume later (using F). That's why in some cases it is preferred over "tail -f". –  dogbane Oct 8 '09 at 15:06
    
tail -f does work, but I'd prefer to work within less. –  TREE Oct 8 '09 at 15:14
    
I see. Did not know that. –  brandstaetter Oct 8 '09 at 15:22
add comment

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.