Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 12-19-2007, 06:08 PM   #1
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"

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
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
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,375

Rep: Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755
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
LQ Guru
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel, 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" "" < 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" "" < /etc/data1



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
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 > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:52 AM.

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