I have a Rocky 8.5 server. Initial settings in Cron as follows (same as our other servers, which work fine forwarding cron output emails)
HOSTNAME=xxxx
CVS_RSH=ssh
MAILTO=yyyy@zzzz
35 * * * * /usr/bin/echo "XXXXX 123 CRON REDIRECT CAPTURE" >/tmp/mycommand.log 2>&1
Which works fine, and writes to the log. But I want it to send an email instead with output. If I get the command to call sendmail direct it works fine also, implying it can email ok.
42 * * * * /usr/bin/echo "XXXXX 123 CRON REDIRECT CAPTURE" | sendmail -v <my email> 2>&1
works fine.
However, if I just have
35 * * * * /usr/bin/echo "XXXXX 123 CRON REDIRECT CAPTURE" 2>&1
This gets written to /var/log/cron
instead of getting emailed.
Oct 27 16:35:01 <host> CROND[1836181]: (<user>) CMD (/usr/bin/echo "XXXXX 123 CRON REDIRECT CAPTURE" 2>&1 )
Oct 27 16:35:01 <host> CROND[1836176]: (<user>) CMDOUT (XXXXX 123 CRON REDIRECT CAPTURE)
Am I missing a step or some other CRON config somewhere ? I can't find any other mention of anything in manpage etc (other than it saying crond -s would forward to a syslog).
I can see cron running with
root 1296 1 0 <date> ? 00:02:35 /usr/sbin/crond -n
sendmail is actually a link to exim if it makes any difference, but seems to work ok when testing from console manually.