siiikooo0743
siiikooo0743

Reputation: 326

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. I can't just go through all the files and check, because it takes to long and uses about 90% of my CPU :(.

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

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

Upvotes: 3

Views: 361

Answers (1)

SzG
SzG

Reputation: 12629

As @Aereaux pointed out you probably need inotify, available in Linux since 2.6.13. See http://en.wikipedia.org/wiki/Inotify

There are inotify-tools available for command line usage as well. http://techarena51.com/index.php/inotify-tools-example/

Upvotes: 4

Related Questions