HyderA
HyderA

Reputation: 21371

How can I use inotify-tools to have an email sent to me when a file in a directory has been added?

Users sometimes add files to a directory on a linux server. I was looking at ways to be informed when a file has been added to this directory. I found inotify-tools:

https://github.com/rvoicilas/inotify-tools/wiki/

But I am not too sure how to go about using it. I can't seem to find a proper documentation on it.

I would appreciate it if anyone with experience in it could guide me.

Upvotes: 2

Views: 5243

Answers (2)

kenorb
kenorb

Reputation: 166399

Try using entr, e.g.

while true; do find path/ | entr -d echo Changed | mail [email protected]; done

or:

while true; do ls path/* | entr -pd echo Changed | mail [email protected]; done

Upvotes: 0

Bart Vanherck
Bart Vanherck

Reputation: 76

With inotifywait you can do what you want, check the manual page.

Upvotes: 2

Related Questions