in reply to script for scanning folder and sending a warning if a file within it is older than 5 minutes

I did find some more hints here, I modified them slightly. This one finds a single file older than 20 minutes and prints a message to stdout:
#!/bin/perl -w use strict; my $mytime=(time); my ($File,$FileStat,$CallOutDir); chdir 'C:/devl/bin' or die "Arghh!!! $!"; opendir(ROOT, ".") or die "Arghh!!! $!"; foreach $File (readdir(ROOT)) { next if $File=~/^\./; if ($FileStat = (stat $File)[9]){ if ($FileStat <= ($mytime - 1200)) { print "File older than 20min found. The file name is $File"; #send mail here.... last; } } }
I'd like it to list all files older than nnn minutes, and I will have to figure out how to make this spit out a file rather than a msg. to stdout.
  • Comment on Re: script for scanning folder and sending a warning if a file within it is older than 5 minutes
  • Download Code