-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash_mailer_with_mutt.sh
27 lines (27 loc) · 1.03 KB
/
bash_mailer_with_mutt.sh
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
#!/bin/bash
#filename: disk_reporter.sh
#description: create a simple report of what folders have the data.
TZ='America/New_York'
current_date=$(date +%Y-%m-%d)
myfolder="/modeling"
echo $current_date
write_folder="/var/tmp"
email_destination"myemail@example.net"
filename="$write_folder/disk_report_$current_date.txt"
echo "filename: $filename"
if [[ -e "$write_folder" ]]; then
echo "****************************************************" > $filename
echo "date: $current_date" >> $filename
echo "subject: disk report from $myfolder" >> $filename
echo "****************************************************" >> $filename
du -ah -t 1G $myfolder| sort -r -n >> $filename
#send email if mutt exists
if [[ -e "/usr/bin/mutt" ]]; then
#note the ~/.muttrc will hold the sender info minumum as follows
#set realname = "My Name"
#set from = "root@myhost.example.net"
cat $filename| mutt -s "disk report from $myfolder" $email_destination -a $filename #file is an attachment
fi
else
echo "error we can't find $write_folder"
fi