I have setup cronjob for the root user. However when the cron fail I should receive an email from the cronjob because I have set MAILTO like this in /etc/crontab :

MAILTO=my@email.com

I have installed mailx using

yum install mailx

But when I look at the cron log I get these lines :

Feb 23 14:13:01 internal crond[6858]: (root) CMD (/var/www/vded/build/bin/sync.sh)
Feb 23 14:13:01 internal crond[6857]: (root) MAIL (mailed 79 bytes of output but got status 0x0001 )

How can I fix this?

UPDATE :

  • I installed mailx and sendmail using yum.
  • I started sendmail.
  • So now sending an email is working from the command line!

I get this error in the maillog :

Feb 23 16:06:01 internal sendmail[7210]: o1NG61cd007210: from=root, size=425, class=0, nrcpts=1, msgid=<201002231606.o1NG61cd007210@internal.fff.com>, relay=root@localhost
Feb 23 16:06:01 internal sendmail[7211]: o1NG61hT007211: from=<root@internal.fff.com>, size=732, class=0, nrcpts=1, msgid=<201002231606.o1NG61cd007210@internal.fff.com>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
Feb 23 16:06:01 internal sendmail[7210]: o1NG61cd007210: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30425, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (o1NG61hT007211 Message accepted for delivery)
Feb 23 16:06:01 internal sendmail[7212]: o1NG61hT007211: to=<root@internal.fff.com>, ctladdr=<root@internal.fff.com> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30972, dsn=2.0.0, stat=Sent

internal.fff.com is the name of the server.

UPDATE :

So in fact if I put the MAILTO=my@email.com as the first line of my crontab (using crontab -e) it is working.

Why is it not working by setting the MAILTO in /etc/crontab ?

Thanks

link|improve this question

70% accept rate
What do the logs from your mail server say? How is mailx configured to send mail? – Bill Weiss Feb 23 '10 at 14:36
Also, try sending something manually using mailx and compare the resulting logs on the mail server. – Chris S Feb 23 '10 at 14:50
/var/log/maillog is empty I haven't configured mailx – benjisail Feb 23 '10 at 14:50
Can you send mail from the command line? – Dennis Williamson Feb 23 '10 at 14:50
Could you answer the recommendations mentioned here first, please? Try sending a mail from the command line, please. – DaDaDom Feb 23 '10 at 15:22
feedback

1 Answer

up vote 0 down vote accepted

So to answer my question :

  • Install mailx yum install mailx
  • Install sendmail yum install sendmail
  • Start sendmail
  • Put the MAILTO line into the crontab using crontab -e : MAILTO=my@email.com and not in /etc/crontab
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.