Blank email on Cron job
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" email@example.com
This command works as intended. It just sends blank emails *only* via cron.
Anyone have any ideas? Driving me buggy :(
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.
Also, cron has a minimal to empty default env, so always specify complete/absolute paths to any cmd used.
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" "firstname.lastname@example.org" < 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" "email@example.com" < /etc/data1
|All times are GMT -5. The time now is 08:27 AM.|