-
Notifications
You must be signed in to change notification settings - Fork 0
/
notifyFileAge.pl
executable file
·44 lines (39 loc) · 1.1 KB
/
notifyFileAge.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/perl
use Net::SMTP;
##############################################################
#
# Author : zack ramjan
# Company : Van Andel Institute
# Description:
# notify genomics staff is trash is full
#
##############################################################
@dirs = ( "/secondary/projects/genomicscore/Core_Research_RawData");
$maxAge = 180;
for my $d (@dirs)
{
next unless -e $d;
my $outfull = `find $d -maxdepth 1 -type d -mtime +$maxAge`;
email("sequencing-notifications\@vai.org","$d report on files older than $maxAge days",$outfull) if length($outfull) > 5;
}
sub email
{
my $toLine = shift @_;
my $from = "run.watch\@vai.org";
my $subject = shift @_;
my $message = shift @_;
my $smtp = Net::SMTP->new('smtp.vai.org');
my @to = split /,/, $toLine;
$smtp->mail($from);
if ($smtp->to(@to)) {
$smtp->data();
$smtp->datasend("To: $toLine\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("\n");
$smtp->datasend("$message\n");
$smtp->dataend();
} else {
print "Error: ", $smtp->message();
}
$smtp->quit;
}