Script to mail Mysql Queries
Dear all,
I have a daily routine task of checking the size of mysql tables in a database in Mysql Database Server. I want to achieve this task through a bash script that runs daily and calculate the size of mysql tables and finally mail it to DBA email-id fore.g adarsh.sharma@orkash.com How this could be achieved . Please guide. I try a simple script to mail but it fails . #!/bin/bash SUBJECT="Automated Security Alert" TO="adarsh.sharma@orkash.com" MESSAGE="/tmp/message.txt" echo "Security breached!" >> $MESSAGE echo "Time: `date`" >> $MESSAGE /bin/mail -s "$SUBJECT" "$TO" It hangs when I run bash a.sh command. However it creates file in /tmp folder and have all contents. Thanks & Best Regards Adarsh Sharma |
Hi,
You don't give the file with the messages to the mail program, mail will silently wait until it receives something to mail. This should work: cat $MESSAGE | mail -s "$SUBJECT" "$TO" Hope this helps. |
All times are GMT -5. The time now is 11:13 PM. |