Joyfulgrind
Joyfulgrind

Reputation: 2836

Inotify compatible Shell script to monitor shell a certain directory

This is first question in Stack overflow. need an inotify compatible script writing that will monitor a certain directory, and if any new files/folders are created in in, copy those files to another folder. I need the script to monitor constantly for changes rather than run periodically. Thanx in advance.

Upvotes: 0

Views: 696

Answers (1)

larsks
larsks

Reputation: 312700

You can use inotifywait, from the inotify-tools page, to build something like this. A typical use:

inotifywait -m /tmp | while read path events name; do
  echo "Now I am going to do something with $name in directory $path."
done

There are oodles of options for controlling how inotifywait operates; consult the man page for details.

Upvotes: 2

Related Questions