Live data from Hacker News

Stop using tail -f (mostly)

brianstorti.com

41–50 of 211 posts

Re: Stop using tail -f (mostly)

#42

Or just tail -f in an emacs buffer

You mean like in multiterm or something? I guess so. In emacs there are always many ways to do things, which is awesome.

You can also open the file and engage auto-revert-mode or auto-revert-mode-tail. In my status bar it shows up as ARev mode.

Also you can bind those to your auto-mode-alist so all .log files get the tail treatment or whatever.

Scrolling can get weird.

Theres some google-able settings for the timeout to revert, default is about a sip of water (a few seconds?) but I guess you could crank it down to 1 second or something.

I like doing this in emacs so its all in the same ecosystem, if I need to cut and paste something weird to test it or put the message into code or even more likely to cut and paste actual error messages into docs or comments, I can do it inside emacs.

Re: Stop using tail -f (mostly)

#44
On current Linux distros, you're more likely to use:

    journalctl -u service-name -f
-f, --follow Show only the most recent journal entries, and continuously print new entries as they are appended to the journal.

Re: Stop using tail -f (mostly)

#45
There's also lnav (http://lnav.org), the Logfile Navigator. It can do what 'tail -f' and 'less' do plus: syntax coloring, filtering, loading compressed files, interleaves log messages from multiple files, and more.

Many of the comments I see on here about using '-F' with tail instead of '-f', live searching, and so on are handled in lnav by default. I would really encourage folks to give it a try.

Re: Stop using tail -f (mostly)

#46
I use tail -f inside tmux anyways, so I already have the extra feature less offers ("navigation mode", searching, etc) without giving up the "watch multiple files" feature.

A much nicer alternative, IMHO.

Re: Stop using tail -f (mostly)

#47
Searching with less is a cool feature, but I think the best thing I learned was to use -F instead of -f with tail thanks to the comments on the article and HN.

Of course I'll probably fail to use any of it because of finger memory just typing out tail -f for me.

Re: Stop using tail -f (mostly)

#48
post #22

It's a nice feature of less, but less is a pager, so you can't pipe the result to `grep` or `sed` or `awk` or something.

I'd wager that 90% of the time that I'm using 'tail -F' I'm also piping it to grep.

This. I use:

tail -f /var/log/x.log | grep foo -A 20 -B 20

Most of the time.

Re: Stop using tail -f (mostly)

#49
post #44

On current Linux distros, you're more likely to use: journalctl -u service-name -f -f, --follow Show only the most recent journal entries, and continuously print new entries as they are appended to the journal.

I prefer the more expressive

  journalctl -fu service-name

Re: Stop using tail -f (mostly)

#50
post #48
post #22

Earlier quoted context omitted.

I'd wager that 90% of the time that I'm using 'tail -F' I'm also piping it to grep.

This. I use: tail -f /var/log/x.log | grep foo -A 20 -B 20 Most of the time.

You know you can also do -C 40 for 40 lines of context instead of -A 20 -B 20
Post reply on HN