Skip to content

Instantly share code, notes, and snippets.

@Neolot
Created January 16, 2017 16:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Neolot/ef7fce2518a8ec71bbe09beb9381ee95 to your computer and use it in GitHub Desktop.
Save Neolot/ef7fce2518a8ec71bbe09beb9381ee95 to your computer and use it in GitHub Desktop.
Send logwatch report to Telegram
#!/bin/bash
# Config
day=$(date +%Y-%m-%d)
filename=/var/cache/logwatch/$day-logwatch.txt
token=<YOUR BOT TOKEN>
chat_id=<YOUR CHAT_ID>
#Check if removed-but-not-purged
test -x /usr/share/logwatch/scripts/logwatch.pl || exit 0
#execute
/usr/sbin/logwatch --output file --filename $filename
chmod 644 $filename
mv $filename /root/logwatch/
curl -F chat_id="$chat_id" -F document=@"/root/logwatch/$day-logwatch.txt" https://api.telegram.org/bot$token/sendDocument >/dev/null 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment