LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 12-19-2007, 06:08 PM   #1
Taleya
LQ Newbie
 
Registered: May 2007
Posts: 8

Rep: Reputation: 0
Blank email on Cron job


Heya guys

I'm trying to automate our RAID check results. When we invoke the command manually, it works fine and emails the results as intended. However, once we schedule it into a cron, we get a blank email

The command is:

tw_cli info c0 | /bin/mail -s "Current RAID Status: $HOSTNAME" foo@blahblah.com

This command works as intended. It just sends blank emails *only* via cron.

Anyone have any ideas? Driving me buggy
 
Old 12-19-2007, 06:56 PM   #2
Uncle_Theodore
Member
 
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896

Rep: Reputation: 71
Try putting your command in a script and calling the script from cron.
For some weird reason cron sometimes doesn't recognize the pipe (|) symbol.
 
Old 12-19-2007, 07:47 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Also, cron has a minimal to empty default env, so always specify complete/absolute paths to any cmd used.
 
Old 12-19-2007, 07:52 PM   #4
Brian1
LQ Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 65
Run the mail command from the terminal and see if it mentions anything. I would assume it says " Null message body; hope that's ok " or something like that. Normally I would do it like this.
/bin/mail -s "Current RAID Status: $HOSTNAME" "foo@blahblah.com" < Text to send for body

Doing that command I think does not work and post same error. If I remember I have to send the data in the body I want sent to a file and then I can email the contents of the file.
Example: Use echo to send data to a file called data1

echo " data you want in the body of the message " > /etc/data1
/bin/mail -s "Current RAID Status: $HOSTNAME" "foo@blahblah.com" < /etc/data1

Brian
 
  


Reply



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
cron job mailing blank output rsmccain Linux - General 4 10-09-2006 04:00 PM
cron job email results... ryedunn Linux - General 7 01-26-2005 10:27 PM
cron job that email a text file paynsr Linux - Newbie 1 03-29-2004 01:36 PM
Cron job , send email mikeshn Linux - General 1 09-21-2003 09:02 AM
Send Email + Txt Attachment Using Cron Job beringer Linux - Newbie 3 01-31-2003 10:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:41 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