LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-15-2011, 08:43 AM   #1
adarshmca
LQ Newbie
 
Registered: Dec 2010
Posts: 28

Rep: Reputation: 0
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
 
Old 02-15-2011, 08:48 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] mysql slow queries? skoinga Linux - Server 1 10-26-2010 09:50 AM
conky and mysql queries. is it possible ? Elve Linux - Software 3 07-31-2010 10:29 AM
mysql queries Eppo Programming 1 07-15-2010 05:39 PM
mysql queries Eppo Linux - Software 3 07-13-2010 12:17 PM
how to view mysql cached queries Sachin.Verma Linux - Software 1 09-29-2007 07:43 AM


All times are GMT -5. The time now is 05:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration