4 ms·
> if looking at a file that might be renamed and stop updating (i.e. log files that are rotated). Without a filename the file descriptor is followed so when for
by martinflack 5y ago
> if looking at a file that might be renamed and stop updating (i.e. log files that are rotated). Without a filename the file descriptor is followed so when for instance access.log becomes access.log.1 your display keeps following access.log.1 not the new access.log which is probably what you want.
I believe that's true if you name a file as well (just tested it on Ubuntu). You keep following the original file you named, even if it becomes renamed; you don't follow a new file by the same name.
Using something like "watch -n5 tail filename" polls every few seconds to show the bottom of a file, and goes for the current file at that filename each time.
- Arnavion 5y ago`tail -F` is what you're looking for. No need to implement it manually with `watch`.
- martinflack 5y agoTIL! Thanks
- dspillett 5y agoAh, checking the man-page it would seem that you need to use the long-form option for the behaviour I described to work: tail --follow=file-to-follow-by-name > watch -n5 tail filename That works too, and for many other uses, but doesn't allow scroll-back which can be significant when a lot of information comes through at once.
- Arnavion 5y ago--follow does not take a file name. There is no difference between long and short options, at least not in this case.
- dspillett 5y agoThe manpage appears to differ on those facts: https://manpages.debian.org/bullseye/coreutils/tail.1.en.html https://manpages.debian.org/bullseye/coreutils/tail.1.en.htm... "Use --follow=name in that case. That causes tail to track the named file in a way that accommodates renaming, removal and creation." I will test to be extra sure when I have a few minutes spare.
- Arnavion 5y agoNothing in that sentence says that --follow takes a filename. `name` in that sentence is not a standin for a filename.
- dspillett 5y agoAh, yes. It looks like I was combining misreading with misremembering, wronging mashing “tail -f some-file” and “tail --follow=name some-file” into “tail --follow=some-file”. Though there is a difference between the short and long forms as -f can't take the extra parameter. “-f=name” is incorrect as it takes “=” to be a short-form option and “-f name” also as it takes “name” to be one of the objects to tail. As per the manpage and --help, for that behaviour you need “-F”. As well as meaning “--follow=name” that also implies “--retry”, though I can't think of a circumstance where this would be a problem.