How can I tell if any file has changed in the subdirectory?

Basically I have a large directory (> 10GB) (each subdirectory only has a few other subdirectories) and I want to do sth for any files that change. I can't just go through all the files and check because it takes a long time and uses about 90% of my cpu :(.

This is how it basically looks:

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):

Check dir
 -> dir changed
   -->Check subA
      -> subA didn't change
   -->Check subB
      -> subB changed
      --> Check subBsubA
          -> subBsubA changed
             --> Check all files

      

But unfortunately changing the file only affects the date when the direct parent directory was modified :(

+3


source to share


1 answer


As @Aereaux pointed out, you probably need one inotify

that is available on Linux since 2.6.13. See http://en.wikipedia.org/wiki/Inotify



For command line use are available inotify-tools

. http://techarena51.com/index.php/inotify-tools-example/

+4


source







All Articles