Detect file change with inotify-tools and execute script

1

I need to detect file changes with inotify-tools. Here is the algorithm:

File changed -> .sh script executed in the same folder, where the file changed.

How can I achieve that?

#!/bin/sh
MONITORDIR="/path/to/the/dir/to/monitor/"
inotifywait -m -r -e create --format '%w%f' "${MONITORDIR}" | while read NEWFILE
do
        sh ./***/execscript.sh
done

I think, that I need to change something after while read NEWFILE and of course, replace **** with a path to that directory.

Andrew

Posted 2017-07-19T09:05:00.107

Reputation: 11

No answers