Hi Guys !
I really agree with all those methods, they are scriptable and efficient,
but the best choice at present day is another...
Is the choice for userland utilities (inotify-tools) to the new kernel
module inotify.
It gives granular auditing for files, directories and sockets in general,
and doesn't introduce prestational overhead, as script may do. sure, you
have to run a 2.6 kernel, i admit ... here is an example sscript from
project's homepage:
inotifywait example 1
#!/bin/sh # A slightly complex but actually useful example inotifywait -mrq
--timefmt '%d/%m/%y %H:%M' --format '%T %f' \ -e close_write /home/billy |
while read date time file; do rsync /home/billy/${file}
rsync://[EMAIL PROTECTED]/backup/${file} && \ echo "At ${time} on ${date},
file ${file} was backed up via rsync" done This may be the most efficient
way to block for changes on files from a shell script.If you don't specify
which event you want to catch, all will be caught, and the event which
occurred is output on stdout.inotifywait example 2
#!/bin/sh EVENT=$(inotifywait --format '%e' ~/file1) [ $? != 0 ] && exit [
"$EVENT" = "MODIFY" ] && echo 'file modified!' [ "$EVENT" = "DELETE_SELF" ]
&& echo 'file deleted!' # etc... inotifywait will return true if an event
you asked for is caught. If an event you didn't ask for is caught, it will
return false; this generally occurs if you listen to a file on a particular
partition and the partition is subsequently unmounted, or if you listen for
a specific event and the file is deleted before that event occurs.
http://en.wikipedia.org/wiki/Inotify &
http://inotify-tools.sourceforge.net/
there are more and more applications for this, check it out and abandon
find,test and diffs...
maybe try perl, dunno, but also give a try to inotify (I REPEAT: IT IS A
OFFICIAL KERNEL MODULE)
Bye, from Italy
Massimiliano
On Sun, Mar 9, 2008 at 10:10 AM, ken Foskey <[EMAIL PROTECTED]> wrote:
> On Sun, 2008-03-09 at 18:40 +1100, david wrote:
> > #!/bin/bash
> > if [ -N /some/directory/ ] ; then
> > echo "change"
> > else
> > echo "no change"
> > fi
> >
> > The object is to identify changes within a directory. This tells me if
> > there are any new or deleted files, but not if files within the
> > directory are modified.
> >
> > Is there a trivial way to do it?
>
> In script something like this:
>
> ls -l >file1
> ls -l >file2
>
> diff file1 file2
>
> In perl
>
> use File::Monitor;
>
>
> --
> Ken Foskey
> FOSS developer
>
> --
> SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
> Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
>
--
Massimiliano Fantuzzi,
IT Professionist & System Builder
www.fantuz.net // [EMAIL PROTECTED]
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html