LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-08-2003, 05:06 AM   #1
Crashed_Again
Senior Member
 
Registered: Dec 2002
Location: Atlantic City, NJ
Distribution: Ubuntu & Arch
Posts: 3,503

Rep: Reputation: 57
Using the 'mail' command to mail a file


Hello all. I have a question that I imagine will be very easy for somebody. I have created a small script that will check my mysql database for any corruption. The script is a cron job and will run once a week. Here is the script:

#!/bin/sh
MYISAMCHK=/usr/bin/myisamchk

#Clear Old Contents Of pulseofac_db.log
cat /dev/null > /var/log/pulseofac_db.log

#Check MyIsam Tables
$MYISAMCHK --fast /var/lib/mysql/pulseofac/*.MYI >> /var/log/pulseofac_db.log

As you can see its fairly straight forward. The output of the myisamchk is concatenated to a text file. I would like to make it so that this text file gets mailed to root@localhost once a week as well. I couldn't find what I was looking for in the man pages of the 'mail' command.

How can I specify a text file to be the subject of the e-mail?
 
Old 08-08-2003, 05:14 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,417
Blog Entries: 55

Rep: Reputation: 3627Reputation: 3627Reputation: 3627Reputation: 3627Reputation: 3627Reputation: 3627Reputation: 3627Reputation: 3627Reputation: 3627Reputation: 3627Reputation: 3627
If you don't dump the result of myisamchk to pulseofac_db.log, then it will be delivered as output of the cronjob (and mailed to root if the settings arent telling to drop mail). Else change the last line to read "$MYISAMCHK --fast /var/lib/mysql/pulseofac/*.MYI| mail -s "Myisamchk results" <mail address>", or if you prefer a MIME attachment add a line: "mpack -s "Myisamchk results" /var/log/pulseofac_db.log <mail address>".
Don't forget to zap the log afterwards.
 
Old 08-08-2003, 05:19 AM   #3
Crashed_Again
Senior Member
 
Registered: Dec 2002
Location: Atlantic City, NJ
Distribution: Ubuntu & Arch
Posts: 3,503

Original Poster
Rep: Reputation: 57
Okay thanks unSpawn. I dumped the whole logging to a text file thing and just had it mail it right to me. I though their would be some sort of switch that you would have to use to specify that it was the content of the e-mail. Guess not.

Thanks man.
 
  


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
Individual user's mail file in /var/spool/mail Swakoo Linux - General 1 09-07-2005 06:33 AM
Exists a mail-client for Fedora, that can read local mail file without deleting? mxn Linux - Software 1 07-10-2004 12:53 PM
Cannot send mail with mail() command in PHP 4.3.4, Apache 2.0.48, Mandrake Linux 10 arcanum Linux - General 3 06-27-2004 06:06 PM
mail is not delivered thru the mail command aadilkhan Linux - General 1 11-18-2003 05:37 PM
cannot receive mail -- mail command andy18 Linux - General 1 09-09-2003 03:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:56 PM.

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
Open Source Consulting | Domain Registration