Score:2

CRON not sending output to email, but writing output /var/log/cron

it flag
Ian

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.

Romeo Ninov avatar
in flag
did you check the mail log?
Ian avatar
it flag
Ian
The email log doesn't have anything in it relevant (it does if it sends something from console etc, but its as though it doesn't try if from cron).
Score:1
it flag
Ian

Fixed by simply restarting cron with

service crond restart

Not sure what the underlying issue was that led to it going astray. Possibly restarting the server with a broken email setup which was later fixed, but cron needed a restart after that was fixed maybe ?

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.