This is along the lines of How to start tailing a file that has not been yet created with a twist: a file with the name already exists.
I have a program that is run multiple times; when the output file name is already in use, it renames the extant file by inserting _XYZ
before the file extension where XYZ
is the smallest integer (e.g., output.out
becomes output_001.out
, or output_002.out
if output_001.out
already exists, etc.), and creates a new output file with the primary name.
If I tail the primary name, even with -F
, it begins tailing the extant file immediately and retains the handle to that inode even when the file is renamed, ignoring the new file.
The program is run on a shared cluster with queue management, so execution begins with long & variable lags.
Is it even possible to tail the new file without waiting for it to be created first? If so, how?
tail
and accomplish something similar withless
. See this Q&A: http://unix.stackexchange.com/questions/74279/how-do-i-less-a-filename-rather-than-an-inode-number/74283#74283. I learned how to use this one yesterday 8-). – slm May 01 '13 at 19:46