Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Using Fedora
FedoraForum Search

Forgot Password? Join Us!

Using Fedora General support for current versions. Ask questions about Fedora and it's software that do not belong in any other forum.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11th July 2006, 05:45 AM
NetNut404 Offline
Registered User
 
Join Date: Aug 2005
Posts: 5
sending mail with the mail command from a crontab..

Hi, I have tested this on several machines, and I can't tell why it is not working.

if I go to a bash shell, and run:

mail -s "Test email" email@domainname.com </tmp/messagebody

the email will send just fine..

but If I put that line in the crontab of any user.. it does not send an email.

I thought.. maybe there is a problem with the redirection.. so I put it in a bash script.. the script works fine from the prompt, but when I put it in cron... no email..

so I am a little annoyed at this point.. because I used to do this all the time.. and now it no longer works...

I am currently running fedora core 5 on this machine with all the updates.. so I started wondering when this stopped working.. I get the same results on several fedora core 5, 4, and 3 machines. I did not have a fedora core 2 machine handy to test.. but I found a fedora core 1 machine, and it worked fine just like I remember..

Any hints you can give me as to what is going on, and how I can fix it?
Reply With Quote
  #2  
Old 11th July 2006, 05:56 AM
bytesniper's Avatar
bytesniper Offline
Registered User
 
Join Date: May 2005
Location: Abq, NM
Age: 35
Posts: 1,158
I ran into a very similar issue writing a backup script at one point. What I did is instead of using a < I used an echo with a pipe.

something similar to this:

echo "messge for the body of the email" | /bin/mail -s"email subject" email_recipient@domain.tld

hth,
joseph
__________________
I am root. If you see me laughing you better have a backup.
Reply With Quote
  #3  
Old 11th July 2006, 11:37 AM
ccrvic Offline
Registered User
 
Join Date: Apr 2006
Posts: 1,092
Quote:
Originally Posted by NetNut404
mail -s "Test email" email@domainname.com </tmp/messagebody

the email will send just fine..

but If I put that line in the crontab of any user.. it does not send an email.
cron executes without an environment, so you have no PATH.

That means "mail" can't be found.

Give it a complete pathspec, and all will bound into life...

Vic.
Reply With Quote
  #4  
Old 12th July 2006, 02:41 AM
NetNut404 Offline
Registered User
 
Join Date: Aug 2005
Posts: 5
Quote:
Originally Posted by ccrvic
cron executes without an environment, so you have no PATH.

That means "mail" can't be found.

Give it a complete pathspec, and all will bound into life...

Vic.
Thanks for the suggestion, but that did not help, even with the absolute path it makes no difference, also if I put in a bad command in the cron it would cause a mail to be generated by cron.

(I also tried seting the path in a script that is called from cron.. made no difference either.
Reply With Quote
  #5  
Old 12th July 2006, 02:43 AM
NetNut404 Offline
Registered User
 
Join Date: Aug 2005
Posts: 5
Quote:
Originally Posted by bytesniper
I ran into a very similar issue writing a backup script at one point. What I did is instead of using a < I used an echo with a pipe.

something similar to this:

echo "messge for the body of the email" | /bin/mail -s"email subject" email_recipient@domain.tld

hth,
joseph
My friend suggested that as well, which I tried, and got the same result.. and of course it works perfecly when run on the command line.
Reply With Quote
  #6  
Old 12th July 2006, 03:33 AM
GrayFox Offline
Registered User
 
Join Date: Sep 2005
Posts: 423
This works for me....

I have the following in one of the cron.daily files....

#!/bin/sh
/bin/mail -s "Daily Cron" jerry <<DOC
The daily cron job ran at `date`
DOC

sends me mail every time cron runs the daily tasks.

Jerry
Reply With Quote
  #7  
Old 12th July 2006, 03:58 PM
NetNut404 Offline
Registered User
 
Join Date: Aug 2005
Posts: 5
Quote:
Originally Posted by GrayFox
I have the following in one of the cron.daily files....

#!/bin/sh
/bin/mail -s "Daily Cron" jerry <<DOC
The daily cron job ran at `date`
DOC

sends me mail every time cron runs the daily tasks.

Jerry
Thanks, I will try it as a test.. although what I was doing was in a users crontab file (a little bit different )
Reply With Quote
  #8  
Old 12th July 2006, 05:48 PM
NetNut404 Offline
Registered User
 
Join Date: Aug 2005
Posts: 5
Originally Posted by GrayFox
I have the following in one of the cron.daily files....

#!/bin/sh
/bin/mail -s "Daily Cron" jerry <<DOC
The daily cron job ran at `date`
DOC

sends me mail every time cron runs the daily tasks.

Jerry



Thanks, I will try it as a test.. although what I was doing was in a users crontab file (a little bit different )

Quote:
Originally Posted by NetNut404
Thanks, I will try it as a test.. although what I was doing was in a users crontab file (a little bit different )

Ok, I tried that.. (used .hourly instead) and that function still works.. but the users crontab is where the problem occurs
Reply With Quote
Reply

Tags
command, crontab, mail, sending

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sendmail -- sending mail with the mail command -- doesn't work :-( carolinevdh Servers & Networking 1 13th August 2009 07:18 PM
Kerio mail server not sending mail dreuzel Using Fedora 0 14th November 2008 10:41 AM
mail command and crontab robghealey Using Fedora 0 31st August 2005 09:35 AM
Brainfart: Sending mail from command line... mattm Using Fedora 3 8th March 2005 07:05 PM


Current GMT-time: 20:18 (Tuesday, 21-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat