0

I have a script which gives output in a file and doing few awk operations on that output file and mixing the output of two files using paste -d and then sending the email of newly created file to email. If i run same script from command line, its giving output and sending email as well, but if i use same command for cron job. Its not sending email and /var/log/cron gives this message. "CROND[6235]: (root) MAIL (mailed 125 bytes of output but got status 0x0043#012)". No info for message code (0x0043#012). Please suggest.

Romeo Ninov
  • 6,677
Rahul
  • 1

1 Answers1

0

From question's comments section, I see that SELinux is preventing your cron job from sending e-mails. The denial does not happen on a manual run from command line because SELinux does not confine interactive sessions by default. Jobs launched by Cron, on the other side, are confined.

I am not sure about the reason why a SELinux denial has been generated in your CentOS 7 system. I tried to run mail command from Cron in a fully-updated CentOS 7 system and the message has been sent successfully. I suggest you to ensure that your server has the latest packages installed (yum upgrade) and perform a SELinux relabeling in entire filesystem (touch /.autorelabel && reboot).

Follow standard SELinux troubleshoot steps in case your cron job continues to fail after the relabeling. Or, instead, you may configure permissive mode permanently:

  • Option 1: Configure SELinux permissive mode on cron service:
# semanage permissive -a crond_t
  • Option 2: Configure SELinux permissive mode on entire system:
# sed -ri.bak 's/^(SELINUX=).*/\1permissive/' /etc/selinux/config && reboot