0

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.

Joyfulgrind
  • 2,762
  • 8
  • 34
  • 41

1 Answers1

2

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.

larsks
  • 277,717
  • 41
  • 399
  • 399
  • Thank you..Can you tell me the logic on how to do the task I asked. Also, can u suggest me some good tutorials on inotify. – Joyfulgrind Jul 31 '12 at 14:35