Hi I am trying to do a script to monitor a dir where files pass through approx every 5 mins but sometimes files may not come in for hours
So the purpose of the script is to monitor by if no files pass through in 1 hour send an email.
So was thinking to use the shell command to grab the time when a file comes in and write to a txtfile.
Now when the files keep coming it will overwrite the old time.
Now if no new files are coming in an hour i got the old time but i having trouble calculating the hour so to trigger out to send an email
this is what i came up with so far
[CODE=perl]#!/usr/bin/perl
#Purpose to monitor a folder
my $IN = "TIMEFILE1" ;
my $IN2 = "TEST";
my $srcdir = "/home/tibco/javastuff/test";
my $tfile = "/home/tibco/scripts/time.txt";
my $tfile2 = "/home/tibco/scripts/time2.txt";
open (OUT ,">$tfile") || "Could not open file $!";
open (FILE, ls -lt | awk -F" " '{print $8}');
while (<FILE>) {
#print $_;
print OUT "$_";
#print $_;
}
close OUT;
close FILE;
###### get system time
open (SYSTEM ,">$tfile2") || "Could not open file $!";
open (FILE2, date | awk -F" " '{print $4}');
while (<FILE2>){
#print $_;
print OUT "$_";
#print $_;
}
close SYSTEM;
close FILE2;
#END[/CODE]
So the purpose of the script is to monitor by if no files pass through in 1 hour send an email.
So was thinking to use the shell command to grab the time when a file comes in and write to a txtfile.
Now when the files keep coming it will overwrite the old time.
Now if no new files are coming in an hour i got the old time but i having trouble calculating the hour so to trigger out to send an email
this is what i came up with so far
[CODE=perl]#!/usr/bin/perl
#Purpose to monitor a folder
my $IN = "TIMEFILE1" ;
my $IN2 = "TEST";
my $srcdir = "/home/tibco/javastuff/test";
my $tfile = "/home/tibco/scripts/time.txt";
my $tfile2 = "/home/tibco/scripts/time2.txt";
open (OUT ,">$tfile") || "Could not open file $!";
open (FILE, ls -lt | awk -F" " '{print $8}');
while (<FILE>) {
#print $_;
print OUT "$_";
#print $_;
}
close OUT;
close FILE;
###### get system time
open (SYSTEM ,">$tfile2") || "Could not open file $!";
open (FILE2, date | awk -F" " '{print $4}');
while (<FILE2>){
#print $_;
print OUT "$_";
#print $_;
}
close SYSTEM;
close FILE2;
#END[/CODE]
Comment