File monitoring with DNotify      2003.11.08 @ 9:04:32 PM
I have an aplication that receives files on a directory. Then there is another scripts that looks for those files and processes in a batch manner. The problem is that polling too often creates a huge overhead on this little machine, and of course waiting for a longer period between batch executions is not acceptable. Looking for a better solution to my problem, I found dnotify. Dnotify is a simple program that makes it possible to execute a command every time the contents of a specific directory change in linux. It is run from the command line and takes two arguments: one or more directories to monitor and a command to execute whenever a directory has changed. Options control what events to trigger on: when a file was read in the directory, when one was created, deleted and so on.

dnotify is written entirely in C, and uses the linux kernel directory notification feature to monitor directories.

EXAMPLES:
Print 'change' to the terminal every time a file (or part of file) in /etc is read.
dnotify -A /etc -e echo change

Execute the script 'informdelete' every time a file in /var/mail is created or deleted.
dnotify -CD /var/mail -e informdelete

RPMs available HERE

Dnotify homepage: http://www.student.lu.se/~nbi98oli/dnotify.html


All knowledge and software published in this website is released under the GNU General Public License (GPL)