r/linux • • Mar 30 '15

Stop using tail -f (mostly)

http://www.brianstorti.com/stop-using-tail/
830 Upvotes

219 comments sorted by

View all comments

350

u/drrlvn Mar 30 '15

The problem is that less +F polls every second while tail -f uses inotify, which is both more efficient and responds faster to change.

22

u/[deleted] Mar 30 '15 edited Mar 30 '15

[removed] — view removed comment

14

u/[deleted] Mar 30 '15

Did you ever found a case when that additional load was actually meaningful ?

2

u/[deleted] Mar 30 '15

[removed] — view removed comment

6

u/[deleted] Mar 30 '15

No, I meant load from polling

1

u/phessler Mar 31 '15

you ever try to read log files from a slow disk? or one that is in the process of dying? poll is hugely painful there.

1

u/[deleted] Apr 01 '15

erm, no, recently written logs will hang around in linux cache in RAM

1

u/holgerschurig Mar 31 '15

Maybe this comes over as arrogant. But for me, if a programmer still needs to poll today, it's either a bad programmer ... or a bad OS design. I look at you, Windows CE !

Also, not needing to poll is about latency, not load.

1

u/[deleted] Mar 31 '15

inotify is great. but it isnt like not having it would hurt tail in most cases.

And it generally doesnt work over many network filesystems so you do have to have polling implementation in codebase anyway

1

u/GLneo Mar 30 '15

It's the principle of the design, use it everywhere and it would pile up.

1

u/[deleted] Mar 31 '15

but you dont in tail. that feature is nice, but nowhere near necesary one. Only real use case is 'i tailed 5k files at once'. Now if it could do 'tail' on metadata (which files/dirs were created/ modified) this could be useful, but there are other tools for that.

Also one could argue that polling inode already cached in RAM might use less CPU than getting a ton of events from busy file

3

u/freedelete Mar 30 '15

inotify is ugly. It's not really surprising.

2

u/imMute Mar 30 '15

The idea, or the API?

1

u/holgerschurig Mar 31 '15

inotify for a single file is reasonable non-ugly.

1

u/freedelete Mar 31 '15

Yeah, that's true.

-19

u/ctx77 Mar 30 '15

Oh wow, FreeBSD is so advanced.. some tool used something more sophisticated than the Linux counterpart..

Lets all switch to FreeBSD immediately. Because it is so much more advanced.

→ More replies (1)