Artificial intelligent assistant

Tailing a New File with an Old Name 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 -F` should already do this.

Create an empty `/tmp/t/file`. Then, in terminal 1, start `tail -F`, and leave it running:


anthony@Zia:~$ tail -F /tmp/t/file
a
b
tail: `/tmp/t/file' has become inaccessible: No such file or directory
tail: `/tmp/t/file' has appeared; following end of new file
c
d


In terminal 2, I did:


anthony@Zia:/tmp/t$ echo a >> file
anthony@Zia:/tmp/t$ echo b >> file
anthony@Zia:/tmp/t$ mv -i file file.old; echo c >> file
anthony@Zia:/tmp/t$ echo d >> file


As you can see, `tail -F` does indeed follow the name, not the inode. Maybe you're using a `tail` that gives different meaning to `-F` (that flag is a BSD extension, copied later by GNU as well), or your version is buggy? You could also try `tail --follow=name --retry` (GNU tail alternate syntax) or `xtail` (which tails an entire directory).

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy ef5cf2d38543f9255b5bb936503cdb1d