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

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



02.04.2014 17:20, David Nelson:

> Hmm. Ok. I tried removing the part using tee so now it's like this:
>  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 >>
> /var/log/mrtg/mrtg.log ; fi
> 
> ....and I am still getting emails to root. Shouldn't this be sending all
> the output to the file and not standard error?

No. First, you redirect stderr to a duplicate of stdout (when it's still
unchanged) and redirect
 stdout afterwards. Do it the other way round:

> env LANG=C /usr/bin/mrtg /etc/mrtg/rm_127_switch-mrtg.cfg >>
/var/log/mrtg/mrtg.log 2>&1

-- 
Regards
  mks


Reply to: