Jasmine Lognnes
Jasmine Lognnes

Reputation: 7127

How to listen only to specific events in inotifywait?

Can someone explain why inotifywait still reports about opened files, when I have excluded open?

mkdir /tmp/a

inotifywait --exclude acess,attrib,close_write,close_nowrite,close,open,moved_to,moved_from,move,delete,delete_self,unmount -r -m /tmp/a/

touch /tmp/a/test
/tmp/a/ OPEN test
/tmp/a/ CLOSE_NOWRITE,CLOSE test

All I am interested in is if new files are made or current files are modified.

I use CentOS 7, if that changes anything.

Upvotes: 6

Views: 3005

Answers (1)

Inian
Inian

Reputation: 85895

The -e event (Listen for specific event(s) only) is different from the --exclude <pattern> which is meant for not processing any events whose filename matches the specified regular expression. Your actual command needed to be without open on the list of events to watch on. For e.g. if you are interested in only create and modify just do

inotifywait -rme create,modify /tmp/a/

inotifywait(1) - Linux man page

Upvotes: 7

Related Questions