Sentry is a commandline utility that performs commands when changes are detected in monitored files or directories

usage

./sentry 
Usage: sentry [options]  [file|dir ..] -- commandline to run

 sentry monitors the listed files or directories for changes, if such occur it
 and invokes the commandline following -- each time something changes.

 Options: 
   -t  N   throttle updates to maxium every N seconds, by default 2s
   -c      monitor for file creations in dir (occurances of % in the
           commandline are replaced with the path of the newly created file.)
   -d      daemonize detach from terminal and run in background
   -v      be verbose, add more v's for more verbosity

download and compiling

To run sentry you must download the source, compile it: (gcc -o sentry sentry.c `pkg-config gio-2.0 --libs --cflags` and put it somewhere in your path.

examples

A common developer use case would be triggering make when files change.

$ sentry *.[ch] -- make

Sentry can act as a file teleporter with files carried over scp

$ sentry -c . -- scp % user@destination.host:target_dir/

Try to make a new git commit everytime something changes in the current directory. (For this command, recursive watching; and better autogenerated commit messages would be useful)

$ sentry . -- sh -c 'git diff|diffstat > /tmp/diffstat ; git commit -a -F /tmp/diffstat'

Feedback loop, where foo and bar contains the timestamps of the last triggering of the others change.

$ sentry foo -- sh -c 'date > bar' & sentry bar -- sh -c 'date > foo' & touch foo