Why tail -f doesn’t work

It is really wired to see tail -f doesn’t work on one of my server. File is changing, but tail doesn’t output anything.I am really curious.

First, I straced tail

strace tail -f file.log

open(“file.log”, O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=1, …}) = 0
lseek(3, 0, SEEK_CUR) = 0
lseek(3, 0, SEEK_END) = 1
lseek(3, 0, SEEK_SET) = 0
read(3, “\n”, 1) = 1
lseek(3, 0, SEEK_SET) = 0
read(3, “\n”, 1) = 1

inotify_init() = 4
inotify_add_watch(4, “file.log”, IN_MODIFY|IN_ATTRIB|IN_DELETE_SELF|IN_MOVE_SELF) = 1
fstat(3, {st_mode=S_IFREG|0644, st_size=1, …}) = 0

Obviously tail monitors file changes using inotify. Maybe the notify is lost for some reason. For comparsion, I did the same experiments on a server that tail worked fine and so did it.

I googled “inotify not working” and finded in inotify FAQ that NFS doesn’t work well with inotify. Does it have something to do with the file system? My server’s file system is overlay, So simple goole “inotify overlay” gives me the answer。


Leave a comment

Your email address will not be published. Required fields are marked *