Hey there, does anyone know how to execute a command whenever a file system change occures within a given directory? I'm running Debian 6.0 and would like to call "make html" when a file/directory was eiter added or modified.

Swatch seems to be what I want but it throws syntax errors.

link|improve this question
feedback

1 Answer

up vote 3 down vote accepted

You should use inotify. Specifically, you can use inotify-tools. See the example shell scripts for some example usage.

Also see incron as a relatively easy way to fire off a script in reaction to a change in a directory.

If you're running Debian 6.0, apt-get install incron should work to get incron installed for your use if you don't have it already.

link|improve this answer
Thank you, this line did the job: while true; do inotifywait -e modify /path/to/directory/ && make; done – tranver Mar 10 '11 at 9:37
ah yes, I should have included the exact usage as you did give enough info in your initial question. Glad it worked! – Phil Hollenback Mar 10 '11 at 9:39
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.