Inotifywait for large directories

The following is indicated in the change inotifywait person

-r, --recursive See all subdirectories of any directories passed as arguments. The clock will be recursively tuned to unlimited depth. Symbolic links are not traditional. Newly created subdirectories will be observed.

Warning. If you use this parameter while browsing the root directory of a large tree, it may take some time until all the inotify clocks are set and events are received at this time. In addition, since one of them will be set for each subdirectory, it is possible that the maximum amount of inotify hours for a user will be reached. The default maximum size is 8192; it can be increased by writing / Transactions / systems / fs / Inotify / max_user_watches.

I believe that every time it is called inotifywait, there is a delay for large directories. Thus, continuous monitoring of a large catalog with a monitoring function, for example,

inotifywait -m /home/user/Documents

more efficient than manual cycle through such a directory (from the example on the manual pages)

while inotifywait /home/user/Documents; do
 #Do Something for each file change
done

while, inotifywait. . , ,

inotifywait -m --callback ./callback.sh /home/user/Documents

callback.sh inotifywait. ?

0
1

:

inotifywait -m /my/directory | while read LINE; do ./do_something.sh $LINE; done

, , script.

perl - API, .

+3

All Articles