scripts/mail-logger.snowboard.sh

26 lines
1008 B
Bash
Raw Normal View History

2023-06-11 00:04:22 +02:00
#!/bin/bash
mkdir -p /tmp/mail-logger
mkdir -p /tmp/mail-logger-meta
2023-06-12 10:45:16 +02:00
mkdir -p /tmp/mail-logger-big
2023-06-11 00:04:22 +02:00
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 "\
2023-06-12 10:51:07 +02:00
Weekly mail report for $(hostname) $(date +"%Y-%m-%dT%H:%M:%S%z").\n\
2023-06-11 00:04:22 +02:00
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
2023-06-11 18:39:22 +02:00
tail -vn 50 /tmp/mail-logger/* >> /tmp/mail-logger-meta/mail.txt
2023-06-11 00:04:22 +02:00
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
2023-06-11 18:39:22 +02:00
rm -rf /tmp/mail-logger
rm -rf /tmp/mail-logger-meta