"Move the old pattern", I assume that you mean the rotation of the file, moving the current and replacing it with a new file.
If so, you can use the --follow=name
option for tail
instead of -f
. This follows the file by name, not the file descriptor, which allows it to continue even if the files are replaced. Then you can leave your tail
running when replacing files and not skip any entries.
For a more robust approach, also include --retry
or just use -f
, which implies --follow=name --retry
.
On the man page:
-f, --follow[={name|descriptor}]
display added data as the file grows; -f
, --follow
and --follow=descriptor
equivalent
--retry
keep trying to open the file even if it is not available when the tail starts or later becomes inaccessible - only useful with -f
-f
same as --follow=name --retry
source share