inotifytools bugs

542 views Asked by At

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?

2

There are 2 answers

0
zeekvfu On

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

1
jørgensen On

inotify watches just aren't recursive. (That is, you will need one per directory if you intend deep level notification.)