Super User is a question and answer site for computer enthusiasts and power users. 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

Does anybody know of tool for Linux that can watch a custom subtree of the filesystem for changes, and executes a custom command when a change occurs ?

Such a tool would be very useful to quickly setup automatic building or uploading of source files.

share|improve this question
up vote 2 down vote accepted

You can use inotifywait from inotifytools:

This command simply blocks for inotify events, making it appropriate for use in shell scripts. It can watch any set of files and directories, and can recursively watch entire directory trees.

share|improve this answer
Thanks, works perfectly. Wrapped in a loop: while [ TRUE ] ; do inotifywait -r . ; ./ ; done – Tomas Sep 16 '10 at 10:49
@Tomas: while true; do – grawity Sep 17 '10 at 14:25
Or for extreme brevity: while :; do – Dennis Williamson Sep 17 '10 at 14:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .