Created
April 30, 2020 10:40
-
-
Save kumarasinghe/959542b3fd96d6dbc0006dfc3a8620b5 to your computer and use it in GitHub Desktop.
Cron Script to email torrent download progress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
my $path = "/folder/to/monitor"; | |
my $mailCMD = "/usr/bin/msmtp"; | |
my $mailTo = 'you@gmail.com'; | |
chdir $path; | |
my @files = `du -hs * | cut -f2`; | |
my @actualSizes = `du -hs * | cut -f1`; | |
my @apparentSizes = `du -hs --apparent-size * | cut -f1`; | |
my $out = "[$path]\n"; | |
for my $i (0 .. $#files){ | |
my $filename = $files[$i]; | |
my $actualSize = $actualSizes[$i]; | |
my $apparentSize = $apparentSizes[$i]; | |
chomp $filename; | |
chomp $actualSize; | |
chomp $apparentSize; | |
$out = $out . "$actualSize / $apparentSize $filename\n"; | |
} | |
$out .= "\n[DISK USAGE]\n" . `df -hl -x tmpfs --output=target,pcent`; | |
print $out; | |
system("printf \"Subject: Torrent Status\n%s\" \"$out\" | $mailCMD $mailTo"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment