[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: getting emails from cron despite redirecting output to a log file



31.03.2014 20:22, David Nelson:

> I have configured mrtg to log network traffic for our organization. This is
> working nicely except at some point while I was fiddling with the scripts
> under /etc/cron.d, which run every 5 minutes to collect snmp data I started
> getting emails to root from cron. I have stared at this and googled a
> bit... yes even the man page, but I don't see what I have messed up here:
> 
>  if [ -x /usr/bin/mrtg ] && [ -r /etc/mrtg/rm_127_switch-mrtg.cfg ] ; then
> env LANG=C /usr/bin/mrtg /etc/mrtg/rm_127_switch-mrtg.cfg 2>&1 | tee -a
> /var/log/mrtg/mrtg.log ; fi

You explicitly pipe mrt's output to tee, which writes it to the given
log-file *and* stdout, which, in turn, will be mailed to you by cron.
If you don't want mail from cron, make sure that there's nothing writen
to stdout. And if you don't want to have something written to stdout,
why do you use tee? Redirect the output directly to the log-file instead.

-- 
Regards
  mks


Reply to: