1

I'm working on RHEL 7.9. In my crontab, I have the following variables and command :

MAILTO=""
SHELL="/usr/bion/ksh"

30 * * * * find /home/me/data/input -name "*.completed" -size +10M -print >> /home/me/jobs/completed.big 2>/home/me/jobs/completed.big.errors

Since everyone has detected the extra o in the SHELL var, you (and I) can tell that all jobs were failing silently.
The /var/log/cron file was filled with all the expected command lines to run.
The journalctl -xe -t crond command only mentioned reloading my personal cron and skipping jobs :

Jan 30 01:21:05 servername crond[26104]: (root) INFO (Job execution of per-minute job scheduled for 01:20 delayed into subsequent minute 01:21. Skipping job run.)
[...]
Feb 05 16:02:01 servername crond[3997]: (me) RELOAD (/var/spool/cron/me)

Seeing no logs from my jobs, I removed the MAILTO variable, and then the local mailbox of my account got messages like:

[... Stripping mail headers]

execl: couldn't exec `/usr/bion/ksh' execl: No such file or directory

Since this error arrives before the command actually launches, I didn't get it in my job logs.

Is there any way to have these errors or at least trap that CRON failed to launch the command in a log ?We have enough mails here, and logs are already monitored.

I have read the Where are cron errors logged? question, but I would like to have a definitive answer on "Can crond errors be found elsewhere than the mails?". This might be a hidden configuration for crond, or anything else, I don't know.

At last, I might even consider tricking the mailbox to redirect into a log, and clean it afterwards.

Mat M
  • 143
  • Not an answer to your question, since it's just "use X instead", but if you are using systemd I highly recommend using systemd timers instead. They come with a whole range of instrumentation, logging, and resource management for free that you have to work really hard to get in cron. For example, in the case described in your question, you could easily set up a global timer failure condition that sends an alert, or bumps a counter, or really anything. – Chris Down Feb 08 '21 at 18:37

1 Answers1

0

According to this reference, the cron daemon has options for this:

-s -m off

Man pages do reference those args:

  • -s sends output to system log (usually something like /var/log/cron)
  • -m off disables sending mails

It is done system-wide, but it fits my needs:

  • Corporate root jobs are quiet (inventory, patches)
  • Mine are not verbose neither
  • Machine is dedicated
Mat M
  • 143