6
I want to tail -f
file but going tailing it after a mv
.
The tail manpage tells me: -f
means --follow=descriptor
so a mv
should not change the inode?
Why does tail -f
stop working after the rename?
6
I want to tail -f
file but going tailing it after a mv
.
The tail manpage tells me: -f
means --follow=descriptor
so a mv
should not change the inode?
Why does tail -f
stop working after the rename?
3
Reading tail
sources, it appears that it does not fail at reading the renamed file, but it fails at monitoring the file status.
More precisely, tail
appears to behave this (simplified) way:
inotify
watch in order to be noticed when something happens to the file;When you move the file, inotify
informs tail
, which in turn decides to drop the file from the list of the monitored files. It appears to be intentional, although it is not clear to me why this is so (and I would expect it to keep monitoring the file after rename). The relevant lines appear to be these.
So, the problem is not with the underlying Linux operating system, but with the way tail
handles file renaming.
2I see youre completley right. For me its a bug in tail
, either in the code or in the documentation. I use tail wihtin a NodeJS script in wrapped it around with my own inotify watcher to re-init tail using the renamed file, not a elegant way but it works. – Psi – 2014-10-13T10:48:42.880
Are you moving across filesystems/partitions? – user1686 – 2014-10-12T18:03:21.230
No, just in the same directory. Tested on Manjaro and Ubuntu 14.04 – Psi – 2014-10-12T18:04:34.293
use tail -F to follow modulo renames, as in http://superuser.com/a/1058674
– timotheecour – 2016-11-16T00:56:12.193