2

I want to trigger an action, when in one of my specified directories, a new file is created. I want to use inotifywait for this purpose. But the problem is that I don't know how to use inotifywait to watch several directories simultaneously. Watching a single directory even recursively is not a problem, but several? Is it possible, or must I run several processes with "inotifywait" in parallel?

6

You can just list directories you want to observe:

$ inotifywait testdir1 testdir2/ -m

Inside application, after instance of inotify is created using inotify_init() function, inotify_add_watch() can be called several times for selected paths. You can find the system limit of watching paths in /proc/sys/fs/inotify/max_user_watches (8192 by default).

  • THX You for help – mackowiakp May 15 '14 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.