News for hackers. Stuff that matters.
Re:Use the 'tail' command to monitor everything by dcsommer on Monday July 12, 2021 @05:49PM (#27815517)
I recommend using `less <FILE>` <shift-F> rather than plain `tail -f <FILE>` because you can ctrl-c to stop the tailing and then search the text using /. You can then resume tailing again later with another <shift-F>.
Re:Use the 'tail' command to monitor everything by anyfoo on Monday July 12, 2021 @05:51PM (#27815533)
I love to press enter a few times to add a few empty lines to serve as a marker. Plus, I set my terminal scrollback buffer to 10000 lines (not a problem nowadays), so cmd-F in the terminal works pretty well. And I prefer the natural/kinetic scrolling of the terminal backlog to less as a fullscreen tty program.

Finally, as the article alludes to, tail can monitor multiple files at once.

Re:Use the 'tail' command to monitor everything by pimlottc on Monday July 12, 2021 @08:02PM (#27816458)
> I love to press enter a few times to add a few empty lines to serve as a marker.

Same! If it weren’t for this, I’d use less, as the searchability is often handy.

But it’s funny how just one tiny (and possible unintended?) “feature” turns out to be so dang useful that I keep using tail.

Re:Use the 'tail' command to monitor everything by anyfoo on Monday July 12, 2021 @09:07PM (#27816778)
Yeah, right? It's not even really a "feature" of anything, just an artifact of how teletype support was originally implemented in UNIX, and yet I've been hitting the enter key for my own "marks" for decades.
Re:Use the 'tail' command to monitor everything by a1369209993 on Tuesday July 13, 2021 @02:35AM (#27818159)
> But it's funny how just one tiny (and possible unintended?) "feature" turns out to be so dang useful that I keep using tail.

"Dangling by a trivial feature"[0] seems to be a pretty common issue when people recommend 'better' software.

0: http://prog21.dadgum.com/160.html

Re:Use the 'tail' command to monitor everything by kevincox on Tuesday July 13, 2021 @10:15AM (#27821254)
I found myself doing this as well and decided to write a simple tool to do it "automatically" for me.

You still can't use it with less, but at least it allows you to mark "segments" of the log without switching to that window and mashing enter.

https://gitlab.com/kevincox/watchlog

Re:Use the 'tail' command to monitor everything by ranko on Tuesday July 13, 2021 @05:14AM (#27818928)
less has its own system of bookmarks: use m followed by a lowercase letter to set a mark and single quote followed by a single letter to jump to that mark. I assume that this means we can have up to 26 bookmarks, though I normally don't go much beyond two.
Re:Use the 'tail' command to monitor everything by petepete on Tuesday July 13, 2021 @05:58AM (#27819170)
You can use capital letters in less too, so at least 52.
Re:Use the 'tail' command to monitor everything by rhizome on Tuesday July 13, 2021 @01:30AM (#27817862)
How many times have you seen the last line of a file you're tailing be something like "00:00 Logfile turned over." Both less and tail stop doing their business when a log is rotated and the inode changes. Stop that by adding or extending an alias:

    alias less='less --follow-name' # still requires <shift>-f to follow
    alias tail='tail -F'
Re:Use the 'tail' command to monitor everything by iso1631 on Tuesday July 13, 2021 @06:06AM (#27819224)
I use tail, head, tac, grep, watch etc all the time to pick out stuff I'm looking for, sometimes I use tail -f, but it's certainly a minority of my tail invocations.
Re:Use the 'tail' command to monitor everything by aerique on Tuesday July 13, 2021 @04:20AM (#27818659)
I've been using `tail -F` for decades but I forgot why!
Re:Use the 'tail' command to monitor everything by gjvc on Tuesday July 13, 2021 @08:54AM (#27820305)
reopens files replaced with a new inode
Re:Use the 'tail' command to monitor everything by iamthad on Monday July 12, 2021 @06:57PM (#27816065)
Equivalently, one can run `less +F <FILE>`
Re:Use the 'tail' command to monitor everything by danielam on Monday July 12, 2021 @08:59PM (#27816744)
This reads the entire file, so for large files you'll likely want something like `less -n +F` if you want to use `less`.
Re:Use the 'tail' command to monitor everything by ryanmonroe on Monday July 12, 2021 @06:55PM (#27816045)
Or hit v after Ctrl-C to open it in a full editor (vi or whatever editor you have as $VISUAL). Quitting the editor resumes tailing.
Re:Use the 'tail' command to monitor everything by asdjlkadsjklads on Monday July 12, 2021 @08:08PM (#27816486)
Okay i wasn't interested in the `less` usage in the GP comment because i use tmux to stop and view logs as they're passing by. However automatically opening in my CLI editor? That sounds sexy as hell!
Re:Use the 'tail' command to monitor everything by bofh23 on Wednesday July 14, 2021 @10:09AM (#27833168)
My less(1) tips are:

Use "-S" to toggle the "--chop-long-lines" option at invocation or in interactive mode. This mode shows only one line on the screen for each line in a file and is helpful when viewing a log with entries much longer than the screen width. When lines are chopped less(1) lets you scroll horizontally with <LEFTARROW>/<RIGHTARROW>. Chopped mode also works in tail mode ("F" command or "+F" option).

As others have mentioned the search "/pattern" and filter "&pattern" commands are awesome and they also work in tail mode.

The -J option toggles the status column which is helpful when using search patterns or paging around a file.

Since less(1) has lots of features and navigation methods it’s good to remember the "h" command to show the help page.

Re:Use the 'tail' command to monitor everything by ithkuil on Monday July 12, 2021 @06:42PM (#27815963)
And you can also use the & command to filter (out) some patterns, while you're tailing.
Re:Use the 'tail' command to monitor everything by emmelaich on Monday July 12, 2021 @11:01PM (#27817261)
Another tip for `less`.

bind next-file and prev-file to N and P instead of the default :n and :p.

Makes it much more convenient to flip through files.

[for some reason macos doesn't have the lesskey command even though it has the manual for it. shrug]

Re:Use the 'tail' command to monitor everything by c0l0 on Tuesday July 13, 2021 @06:31AM (#27819393)
You can stop output on a terminal (emulator) by exercising flow control. If you get overwhelmed by `tail` (or a similar tool's) output, hit ^S. If you are ready to resume, strike ^Q.
Re:Use the 'tail' command to monitor everything by ian-bateman on Monday July 12, 2021 @07:20PM (#27816231)
>couldn’t you pause/unpause the stdout with ctrl-s/ctrl-q instead?

edit: child comment is a better solution.

Re:Use the 'tail' command to monitor everything by knodi123 on Monday July 12, 2021 @07:35PM (#27816324)
uh... doesn't watch just run the command over and over? I would have thought this would just print the entire file every n seconds. Now using tail with that instead of cat....
Re:Use the 'tail' command to monitor everything by MawKKe on Monday July 12, 2021 @07:25PM (#27816271)
couldn’t you pause/unpause the stdout with ctrl-s/ctrl-q instead?
Re:Use the 'tail' command to monitor everything by rzzzt on Monday July 12, 2021 @06:21PM (#27815813)
tailf is also a good replacement for tail --follow=name, it uses inotify internally to only look at the file when there is a change.