Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Monitor Directory modification

by needperlhelp (Acolyte)
on Nov 12, 2006 at 15:58 UTC ( #583571=perlquestion: print w/replies, xml ) Need Help??

needperlhelp has asked for the wisdom of the Perl Monks concerning the following question:

Do we have a proactive way to check if a directory is modified or not. do we have select / poll like command which unblocks on directory getting modified. Suggestions welcomed.

Replies are listed 'Best First'.
Re: Monitor Directory modification
by Rossco (Initiate) on Nov 12, 2006 at 20:17 UTC

    Perhaps taking a look at the following modules may help:

    Win32::ChangeNotify - Monitor events related to files and directories
    POE::Component::DirWatch - POE directory watcher

    If neither does exactly what you want taking a look at the code in the poe module and "File::Compare - Compare files or filehandles" might give you inspiration.


Re: Monitor Directory modification
by ambrus (Abbot) on Nov 12, 2006 at 17:03 UTC

    Linux has an api for this. It's the F_NOTIFY fcntl. Read the fcntl(2) manpage for details.

Re: Monitor Directory modification
by aufflick (Deacon) on Nov 13, 2006 at 01:21 UTC
    The most efficient way I am aware of to do this is using the fam daemon/api from SGI (and that is shipped by default on a number of Linux distros these days).

    See SGI::FAM and

Re: Monitor Directory modification
by ides (Deacon) on Nov 12, 2006 at 16:55 UTC

    None that I'm aware of.

    Best way to do this is to have whatever is modifying the directory ( adding files, editing files, etc ) drop a empty file of a specific name, launch a script, or some other marker when it has modified something.

    Second best option, is to just manually, using either cron or a long running process with some sleep() intervals, look for changes in the files.

    Hope that helps.

    Frank Wiles <>

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://583571]
Approved by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2023-09-30 08:53 GMT
Find Nodes?
    Voting Booth?

    No recent polls found