Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Another answer on superuser for a very similar question. – cfi Nov 9 '12 at 10:36
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.

share|improve this answer
Thank you, this line did the job: while true; do inotifywait -e modify /path/to/directory/ && make; done – mbh 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
Link to incron broken. Here's a possible replacement – cfi Nov 9 '12 at 10:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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