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

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



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?

Here is the whole error message I am getting from MRTG. MRTG seems to be working like a champ BTW. I would just like to stop these error messages

Thanks
David


Cron <root@backuppc> if [ -x /usr/bin/mrtg ] && [ -r /etc/mrtg/elem_switch-mrtg.cfg ] ; then env LANG=C /usr/bin/mrtg /etc/mrtg/elem_switch-mrtg.cfg 2>&1 >> /var/log/mrtg/mrtg.log ; fi
Content-Type: text/plain; charset=UTF-8
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>

Subroutine SNMP_Session::pack_sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
 at /usr/share/perl5/SNMP_Session.pm line 149
Subroutine SNMP_Session::unpack_sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
 at /usr/share/perl5/SNMP_Session.pm line 149
Subroutine SNMP_Session::sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
 at /usr/share/perl5/SNMP_Session.pm line 149
Subroutine SNMPv1_Session::pack_sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
 at /usr/share/perl5/SNMP_Session.pm line 608
Subroutine SNMPv1_Session::unpack_sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
 at /usr/share/perl5/SNMP_Session.pm line 608
Subroutine SNMPv1_Session::sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
 at /usr/share/perl5/SNMP_Session.pm line 608



On Tue, Apr 1, 2014 at 7:05 AM, David Nelson <david.nelson01@gmail.com> wrote:
MKS,

Thank you ! That clears that up for me. I used tee because the crontab I was using as a model was generated by the default install on Debian. I checked the man page for tee because I had never seen it before, but it still didn't register in my mind what it was doing exactly. Thank you again for clearing that up for me, and thank you to others who took time to reply also.

Have a great day!
David


On Tue, Apr 1, 2014 at 5:12 AM, Markus Schönhaber <debian-user@list-post.mks-mail.de> wrote:
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


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: [🔎] 533A90FB.80500@list-post.mks-mail.de" target="_blank">https://lists.debian.org/[🔎] 533A90FB.80500@list-post.mks-mail.de




Reply to: