26 lines
1007 B
Bash
Executable File
26 lines
1007 B
Bash
Executable File
#!/bin/bash
|
|
mkdir -p /tmp/mail-logger
|
|
mkdir -p /tmp/mail-logger-meta
|
|
mkdir -p /tmp/mail-logger-big
|
|
|
|
cp /var/log/borg-cron.log /tmp/mail-logger-big
|
|
|
|
cat /tmp/mail-logger/* >> /tmp/mail-logger-meta/combined.log
|
|
cat /tmp/mail-logger-big/* >> /tmp/mail-logger-meta/combined.log
|
|
|
|
echo -e "\
|
|
Daily mail report for $(hostname) $(date +"%Y-%m-%dT%H:%M:%S%z").\n\
|
|
A summary of the logs is below.\
|
|
If you want to see the complete logs, open the attachment of this E-Mail.\n\n\
|
|
==================================================================================================\
|
|
=====================\n\
|
|
" > /tmp/mail-logger-meta/mail.txt
|
|
|
|
tail -vn 50 /tmp/mail-logger/* >> /tmp/mail-logger-meta/mail.txt
|
|
tail -vn 50 /tmp/mail-logger-big/* >> /tmp/mail-logger-meta/mail.txt
|
|
|
|
mail-script "logs@cscherr.de" "logs@cscherr.de" "daily mail report for $(hostname) $(date +"%Y-%m-%d")" /tmp/mail-logger-meta/combined.log < /tmp/mail-logger-meta/mail.txt | sendmail -oi -t
|
|
|
|
rm -rf /tmp/mail-logger
|
|
rm -rf /tmp/mail-logger-meta
|