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