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

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



Hi

On Mon, Mar 31, 2014 at 01:22:31PM -0500, David Nelson wrote:
> Hello,
> 
> 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

well... if mrtg produces any output, it *will* be e-mailed as per
normal cron output. AND it will be appended to
/var/log/mrtg/mrtg.log...

PS: If you want to take advantage of syslog here (and the standard log
rotation) it is relatively simple: use logger - e.g.:

    something | something | logger --tag "davids-mrtg"

> To clarify the above is not the whole line from the file under /etc/cron.d/. I
> don't have access to that system right now so I am just posting the command
> part that I keep getting in my email.

Seeing the output might help too - more eyes and all that.

> 
> Also, I have jobs for a few different switches setup like this. Is there any
> reason I can't let the output all go into the same log file? Hmmm... Wonder if
> it's a problem that all these jobs are trying to write to the same log file at
> once?

Probably not. But it's easy to send stuff via syslog as noted
above. Then you don't have to bother about maintaining the log files,
and can also log to a centralised server etc etc. All the normal
syslog stuff.

Hope this helps
-- 
Karl E. Jorgensen


Reply to: