Inotifywait Not Detecting Links

Inotifywait Not Detecting Links

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?

1 Answer

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.

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Alexander Ross
Author

Alexander Ross

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.