M
mr.vlad.dracula
Do you think you can point me on the right direction?
Desired result: Monitor directories indefinitely, print on screen if a
file found is older than 1 minute. It's supposed to bypass
subdirectories, hidden files/directories as well.
Problem: if a file is there already on any of the directories, it will
print out the file just fine. However, if I delete that file and drop
another one, wait a minute or more, nothing displays. It's not really
going inside the directories after the first time.
Thank you...
#!/usr/bin/perl
use warnings;
use strict;
use File::Find;
my @directories = ("/home/foo/dir1","/home/foo/dir2");
my $MINUTES = 0.0007; #<-1 min expressed in days
my $condition = 1;
#supposedly loops forever
while ($condition == 1){
find(\&process, @directories, no_chdir => 1);
}
sub process {
#only files, not directories. skip . and .. files
if (-f $_ and !/^\./){
if (-M $_ >= $MINUTES){
print "$File::Find::name\n";
}
}
sleep 1;
}
Desired result: Monitor directories indefinitely, print on screen if a
file found is older than 1 minute. It's supposed to bypass
subdirectories, hidden files/directories as well.
Problem: if a file is there already on any of the directories, it will
print out the file just fine. However, if I delete that file and drop
another one, wait a minute or more, nothing displays. It's not really
going inside the directories after the first time.
Thank you...
#!/usr/bin/perl
use warnings;
use strict;
use File::Find;
my @directories = ("/home/foo/dir1","/home/foo/dir2");
my $MINUTES = 0.0007; #<-1 min expressed in days
my $condition = 1;
#supposedly loops forever
while ($condition == 1){
find(\&process, @directories, no_chdir => 1);
}
sub process {
#only files, not directories. skip . and .. files
if (-f $_ and !/^\./){
if (-M $_ >= $MINUTES){
print "$File::Find::name\n";
}
}
sleep 1;
}