Re: watching directories recursively

From: Darryl Dixon - Winterhouse Consulting <darryl.dixon_at_winterhouseconsulting.com>
Date: Fri, 26 Sep 2008 10:06:03 +1200 (NZST)

Hi Digna,

I've posted to this list once or twice now when people ask this question:

Pyinotify (http://pyinotify.sourceforge.net) is an excellent programme
based on the inotify framework that allows recursive watching of
directories, and can be relatively easily extended to perform various
actions depending on what events it sees, or, some other program can
simply tail the logfile it emits and take action based on what appears in
there.

I have made some significant modifications to the pyinotify code to allow
it to startup very quickly recursively monitoring very large directory
trees (millions of files, 10s-of-thousands of subdirectories), operate as
a daemon, etc. This operates in Production for well over a year now (since
roughly mid last year) capturing roughly 20-30,000 file
move/add/change/delete events per day. I am happy to forward my modified,
ready-to-use source on to anyone interested in a solution until incron has
been updated :)

many regards,
Darryl Dixon
Winterhouse Consulting Ltd
http://www.winterhouseconsulting.com

> Hello,
>
> I am working in a proyect in which I need to watch directories
> recursively. As I know that isn't still supported, I tried to do a little
> hack (but it doesn't work):
>
> *I have added to my incron table a line that runs the script dirmon.sh
> everytime a directory is created inside the directory I want to monitor:
>
> /dir_to_watch IN_CREATE script_to_exec.sh
> /dir_to_watch IN_ONLYDIR IN_CREATE dirmon.sh $@/$#
>
> That script, dirmon.sh, is intended to add to my incron table the lines to
> start watching that new subdirectory:
>
> #!/bin/bash
> echo $1 IN_CREATE sanity.sh>>/var/spool/incron/root
> echo $1 'IN_ONLYDIR IN_CREATE dirmon.sh $@/$#'>>/var/spool/incron/root
>
> The problem is it doesn't write anything to my incron table. If I try to
> write it to another file, it does work, but not with the "root" file.
> Maybe
> because it is in use?
>
> Is there any way I could make this work?
>
> Thanks,
>
> Digna
>
Received on Fri Sep 26 2008 - 00:25:58 CEST

This archive was generated by hypermail 2.2.0 : Tue Jun 05 2012 - 22:14:21 CEST