Reputation: 109
I'm using inotifytools to monitor a directory recursively. when I use the following command
inotifywait ./test -m
after the command, if I create a director under ./test
, assuming ./test/test2
. Then if I do something under test2
, for example, delete a file, or add a file, it's very strange that there was no event occurred.
It seems that there is no watch on test2
.
Is that a bug or I just use in the wrong way?
Upvotes: 1
Views: 571
Reputation: 3393
man 1 inotifywait
, you will get the following output:
-r, --recursive
Watch all subdirectories of any directories passed as arguments. Watches will be set up recursively to an unlimited depth. Symbolic links are not traversed. Newly created subdirectories will also be watched.
Warning: If you use this option while watching the root directory of a large tree, it may take quite a while until all inotify watches are established, and events will not be received in this time. Also, since one inotify watch will be established per subdirectory, it is possible that the maximum amount of inotify watches per user will be reached. The default maximum is 8192; it can be increased by writing to /proc/sys/fs/inotify/max_user_watches.
By default, inotifywait
won't monitor subdirectories, so you need -r, --recursive
option to force that. So the command you need will be like this:
inotifywait -rm test
Upvotes: 1
Reputation: 10549
inotify watches just aren't recursive. (That is, you will need one per directory if you intend deep level notification.)
Upvotes: -1