Java WatchService在某些文件夹上不起作用 [英] Java WatchService doesn't work on some folders
问题描述
我想使用 Java 7 WatchService 来监视 / proc
文件夹,但这不起作用(文件夹中的更改不会被报告)。我已经测试了其他文件夹,比如 / home / user / Desktop
和 / tmp
,它可以工作。可能是什么原因?是因为权限? / proc
显然属于root,而另一个文件夹属于登录用户。然而, / tmp
也由root拥有,但是它起作用。我正在使用这个基本的实施进行测试。
我的操作系统是Ubuntu 13.10 64bit。这是因为/ proc不是一个正常的文件系统,因此不支持inotify:
/ p>
https://unix.stackexchange.com/questions/90627/notify-of-changes-on-a-file-under-proc
https://unix.stackexchange.com/questions/74713/how-frequently-is -pro-file-system-updated-on-linux?rq = 1
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.
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
这篇关于Java WatchService在某些文件夹上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!