r/commandline • u/speckz • Mar 30 '15
Stop using tail -f (mostly)
http://www.brianstorti.com/stop-using-tail/7
u/greyfade Mar 30 '15
This is what I use most and multitail for. Bonus points: multitail will read the new file when syslog rolls it over.
4
1
u/socium Mar 31 '15
Bonus points:
multitailwill read the new file whensyslogrolls it over.Won't
tail -Fdo the same as well?-1
u/greyfade Apr 01 '15
No, it doesn't. At the very least, BSD
taildoesn't, and I'm pretty sure GNUtaildoesn't.2
u/buried_treasure Apr 01 '15
That's pretty much the sole purpose of -F (as opposed to -f) for GNU tail:
--retry keep trying to open a file if it is inaccessible each file -f, --follow[={name|descriptor}] output appended data as the file grows; an absent option argument means 'descriptor' -F same as --follow=name --retry
3
u/randomwolf Mar 31 '15
The only let down for me is that I usually tail a log file before I attempt to do some task which is going to generate log entries. I'll start the tail, the press enter a few times to make it clear where the new entries start. And less just holds the cursor where it is. Still, kind-of neat after using tail for all these (gasp 24!) years.
2
u/RX_AssocResp Mar 30 '15
My terminal has search. And I can scroll it just fine.
That said, I use F sometimes. And journalctl offers this too.
2
u/thelastknowngod Mar 31 '15
99% of my work is done in screen. I just do a Ctrl-A + Esc to use copy mode to search. That stops the output and I just need to hit Esc to resume normal mode.
2
u/codebam Mar 31 '15
why screen and not tmux?
3
u/thelastknowngod Mar 31 '15
I started using screen in like 2001 or 2002.. long before tmux came out. I've just never seen a convincing argument to get me to switch. I can already do everything tmux provides in screen.
1
u/codebam Mar 31 '15
well I guess it's not worth it to you to switch. I just sorta said 'why not' myself actually, since tmux was available at the time I made the choice.
2
1
u/arcticblue Mar 30 '15
Oh, that's pretty neat! I didn't know less could do that. But why the weird "+F" flag?
4
u/sysop073 Mar 30 '15
Fis the key to hit in less to do this ("forward forever");+on the command line means "open the file and pretend I hit this key"
15
u/Nadiar Mar 31 '15
I disagree with their reasoning behind using tail -f. "Simply put, it allows you to switch between navigation and watching mode." Most of the time I'm doing a tail, I'm more interested about what is going into it, and am probably going to be interested in limiting what I'm watching, or doing something else.
like tail -f /var/log/messages | grep -v some_common_garbage | ccze -A
This is more like "hey, you should know about less +F"