views:

63

answers:

4

I want to run a shell script when a specific file or directory changes.

How can I easily do that?

+1  A: 

Check out the kernel filesystem monitor daemon

http://freshmeat.net/projects/kfsmd/

Here's a how-to:

http://www.linux.com/archive/feature/124903

Brian Clements
+5  A: 

Use inotify-tools.

Frédéric Hamidi
Dennis Williamson
A: 

As mentioned, inotify-tools is probably the best idea. However, if you're programming for fun, you can try and earn hacker XPs by judicious application of tail -f .

Yoric
+1  A: 

Here's another option: http://fileschanged.sourceforge.net/

See especially "example 4", which "monitors a directory and archives any new or changed files".

slowdog