Ad Widget

Collapse

Folder monitoring

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • davidv
    Junior Member
    • Apr 2009
    • 6

    #1

    Folder monitoring

    Hello,

    I try to find a solution on "how I can monitor a folder".
    what I need to do is:
    if there are files (the file names are never the same) in the folder we need to check how old they are and if they are older then 1 hour we need to send a mail that there are files older then 1 hour.

    can someone help me.

    thanks in advance.

    best regards

    David
  • trikke
    Senior Member
    • Aug 2007
    • 140

    #2
    Hi DavidV,

    I had the same "Problem" and use this small perl script that i included as UserParamerter:
    Code:
    #!/bin/perl
    use File::Find ;
    find( {wanted => sub{-f && -M > 1/24 && ($ARGV[0]."/".$_ eq $File::Find::name) && print "$_\t" || print "NOK\n" }, no_chdir => "0" },$
    ARGV[0] ) ;
    
    exit 0
    greets
    Patrick

    Comment

    • davidv
      Junior Member
      • Apr 2009
      • 6

      #3
      hi trikke,

      thanks for that.

      is this platform independent?

      FYI: i need it for windows platform

      Comment

      • trikke
        Senior Member
        • Aug 2007
        • 140

        #4
        Hi Davidv,
        since it's a perl script it should be plattform independent!
        Just check.
        If not U should write another perl script with something like this:

        <CODE>
        use File::stat ;

        print OUT "Getting timediff\n" ;
        $st = stat("$file_found") ;
        $delta_seconds = check_time($st->mtime) ;
        print OUT "diff: $delta_seconds\n";
        if ( $delta_seconds > 300 )
        {
        #print "no update since ($time_now-$file_time) seconds!\n";
        print "1\n";
        } else {
        #print "file got updated in the last ($time_now - $file_time) seconds!\n";
        print "0\n"
        };
        <\CODE>

        Comment

        Working...