monitor your filesystem events with inotify-tools

I looking for the way to mirror files on my server to others when something're updated and found that inotify is a good idea in this case.
Thanks for inotify-tools project, c library and set of command line programs for linux provide interface to inotify, that let me avoid from c code.

On ibex, i get it by..

pnix@pnix-a7n:~$ sudo aptitude install inotify-tools
[sudo] password for pnix:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
The following NEW packages will be installed:
inotify-tools libinotifytools0{a}
0 packages upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 39.0kB of archives. After unpacking 201kB will be used.
Do you want to continue? [Y/n/?] y
Writing extended state information... Done


Below is example shell script i use to moniter and update file to remote host.
while inotifywait -rq -e close_write /folder_to_moniter; do
rsync -av /folder_to_moniter -e "ssh -l pnix" pnix@remotehost:/home/pnix/tmp

for Java api look here


Amri Shodiq said...

Thanks. This is really good information. It works!

Russell said...

Wow, you really seem to know your stuff.

News Blog said...

Nice Post
Steven Spurrier

Anonymous said...
This comment has been removed by a blog administrator.