Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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
    Hi

    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.

    Cheers

    Rossco
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 http://oss.sgi.com/projects/fam/

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 <frank@revsys.com>
    www.revsys.com

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2022-08-10 23:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?