Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

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.

share|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
    
Link to incron broken. Here's a possible replacement –  cfi Nov 9 '12 at 10:39
add comment

Your Answer

 
discard

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.