Score:0

inotifywait not detecting links

cn flag

I have successfully created a watcher for modifications inside a directory, recursively:

inotifywait -m -r -e modify --format '%w%f' "$Path" | while read File
do
    echo "File $File is modified"
done

However, I have some symbolic links inside that directory. And when I open them in an editor and change them, inotifywait does not print anything.

I think it's because the actual files are in another directory.

How can I tell inotifywait to detect changes of links too?

Score:1
uz flag
Jos

You can't. inotifywait watches the symbolic links themselves, not the files they point to.

Behind the scenes inotifywait uses the inotify syscall with the IN_DONT_FOLLOW flag, which causes this behaviour. If you want to change that you would need to write your own inotifywait, without the flag.

I got this from this discussion.

Saeed Neamati avatar
cn flag
Thanks @Jos, now I know that I need to spend two more weeks to find out another solution. That's the life we have chosen as people of modern technologies.
uz flag
Jos
Another solution would be to...run `inotifywait` on the linked directories themselves, maybe? There, I saved you two weeks. ;-)
Saeed Neamati avatar
cn flag
:)), thank you. However, if I watch **linked file** instead of **linking file**, then I have to find out the **linking file**.
ahmet alp balkan avatar
sy flag
This is not true if you're using `inotifywait` v3.14. It follows symlinks recursively because it doesn't use the `IN_DONT_FOLLOW` option. Newer versions offer a `-P`/`--no-dereference` option (which is not available on v3.14).
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.