Re: watching directories recursively

From: Darryl Dixon - Winterhouse Consulting <>
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 ( 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

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

> 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
> everytime a directory is created inside the directory I want to monitor:
> /dir_to_watch IN_CREATE
> /dir_to_watch IN_ONLYDIR IN_CREATE $@/$#
> That script,, is intended to add to my incron table the lines to
> start watching that new subdirectory:
> #!/bin/bash
> echo $1 IN_CREATE>>/var/spool/incron/root
> echo $1 'IN_ONLYDIR IN_CREATE $@/$#'>>/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