inotify -watch for file to change

Here is a simple command for you. It uses inotify tools. So first you need to install :

sudo yum install inotify-tools

and then you can try something like this:

while true; 
do 
inotifywait -r -e modify --exclude=".swp" . && make; 
done

Here, once the file changes, we are running make, but you can do anything you want.

 

 

Enhanced by Zemanta

Inotify Example: Introduction to Inotify with a C Program Example


Inotify Example: Introduction to Inotify with a C Program Example:

inotify utility is an effective tool to monitor and notify filesystem changes. You can specify a list of files and directories that needs to be monitored by inotify. This library is used by various other programs. For example, CPAN module Linux::Inotify is developed based on this library.
iNotify Execution Flow

On a high-level, you do the following with inotify utility.

\"Reblog