[英]How can I detect if some file in a subdir changed?
Basically I have a big directory (>10GB)(each subdir only has a few other subdirs) and want to do sth to any files that changes. 基本上我有一个大目录(> 10GB)(每个子目录只有几个其他子目录),并希望对任何更改的文件做某事。 I can't just go through all the files and check, because it takes to long and uses about 90% of my CPU :(.
我不能只是浏览所有文件并检查,因为它需要很长时间并占用我CPU的90%左右:(。
This is how it looks basically: 这基本上是这样的:
dir
dir/subA
dir/subA/subAsubA
dir/subA/subAsubB
...
dir/subB
dir/subB/subBsubA
dir/subB/subBsubB
...
dir/SubC
dir/SubD
...
My thought was like this(file "test" in subBsubA chaged): 我的想法是这样的(subBsubA chaged中的文件“test”):
Check dir
-> dir changed
-->Check subA
-> subA didn't change
-->Check subB
-> subB changed
--> Check subBsubA
-> subBsubA changed
--> Check all files
But sadly the change of a file only effects the modification date of the direct parent directory :( 但遗憾的是,文件的更改只会影响直接父目录的修改日期:(
As @Aereaux pointed out you probably need inotify
, available in Linux since 2.6.13. 正如@Aereaux指出的那样,你可能需要
inotify
,自2.6.13以来在Linux中可用。 See http://en.wikipedia.org/wiki/Inotify 见http://en.wikipedia.org/wiki/Inotify
There are inotify-tools
available for command line usage as well. 还有
inotify-tools
可用于命令行使用。 http://techarena51.com/index.php/inotify-tools-example/ http://techarena51.com/index.php/inotify-tools-example/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.