问题
I want to use Java 7 WatchService to monitor /proc
folder, but that's not working (changes made in the folder are not reported). I've tested other folders such as /home/user/Desktop
and /tmp
and it works. What could be the reason? Is it because of permissions? /proc
is obviously owned by root whereas the other folder is owned by logged in user. The /tmp
however is also owned by root, but it works. I'm using this basic implementation to test it.
My OS is Ubuntu 13.10 64bit. Oracle Java 1.7.0_51.
回答1:
It's because /proc isn't a normal filesystem and therefore doesn't support inotify:
https://unix.stackexchange.com/questions/90627/notify-of-changes-on-a-file-under-proc https://unix.stackexchange.com/questions/74713/how-frequently-is-the-proc-file-system-updated-on-linux?rq=1
来源:https://stackoverflow.com/questions/22043557/java-watchservice-doesnt-work-on-some-folders