4

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.

2
  • did you check the mail log? Commented Oct 27, 2022 at 17:12
  • 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). Commented Oct 27, 2022 at 18:38

1 Answer 1

3

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 ?

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.