[lug] Scripting question
Paul Nowosielski
paulnowosielski at yahoo.com
Fri Dec 21 20:30:15 MST 2012
Dear All,
Thank you all for your suggestions. I will implement and let you know
how it goes.
Happy holiday and thank you,
kind regards,
Paul
On 12/21/12 7:45 PM, Jeffrey S. Haemer wrote:
> What Lee said. Bash even lets me say it like this:
>
> cmd &>> /var/tmp/logfile.txt
>
> but cron uses /bin/sh by default.
>
> I've made enough "Heck. That's only in bash" mistakes in cron that I
> start my crontabs as described here:
>
> http://seejeffrun.blogspot.com/search?q=crontab
>
> which also says how I avoid losing cron's mail: I let Google store it
> for me. :-)
>
>
> On Thu, Dec 20, 2012 at 10:41 PM, Lee Woodworth
> <blug-mail at duboulder.com <mailto:blug-mail at duboulder.com>> wrote:
>
> On 12/20/12 21:03, Jed S. Baer wrote:
> > On Fri, 21 Dec 2012 10:04:21 +0700
> > Paul Nowosielski wrote:
> >
> >> Here is the commands I am running and the script I call:
> >>
> >> /bin/date >> /root/scripts/bandwTest; /root/scripts/bandwidth.sh >>
> >> /root/scripts/bandwTest;
> >
> > As Davide pointed out, you're likely missing the PATH. Easiest
> thing to
> > do is invoke iptables as /sbin/iptables (or whatever the full
> path is).
> >
> > Another question would be where is STDERR going? Off the top of
> > my head, I don't remember how cron handles that. Capturing it would
> > likely show you what's wrong. I often redirect it in the script
> itself,
> > but there are other ways to do it too. So my rendition of your
> script
> > would look like:
> >
> > #!/bin/bash
> > exec >> /root/scripts/bandwTest 2>>&1
>
> Don't know if that will work, but this does work for me:
>
> # cmd >>/var/tmp/logfile.txt 2>&1
>
> The order of the redirections matters, the logic is approximately:
> 1) redirect fd 1 to /var/tmp/logfile.txt in append mode,
> 2) redirect fd 2 to a duplicate of fd 1 (thus inheriting the
> append mode).
>
> Jeff H. probably knows the more rigorous description of what this
> does.
>
> > echo
> > echo "Bandwith out:"
> > /sbin/iptables -L -v |grep OUTPUT |awk '{print $7}'
> >
> > However, I've never tried that using the concat style
> redirection, so I
> > don't know for sure it'll work. Usually, I do:
> >
> > exec > foo.log 2>&1
> >
> > And that's just from memory; consulting the exec manpage would
> be a good
> > thing.
> >
> > And if you have no luck with this, might be good to see your crontab
> > entry.
> > _______________________________________________
> > Web Page: http://lug.boulder.co.us
> > Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> > Join us on IRC: irc.hackingsociety.org
> <http://irc.hackingsociety.org> port=6667 channel=#hackingsociety
>
> _______________________________________________
> Web Page: http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> Join us on IRC: irc.hackingsociety.org
> <http://irc.hackingsociety.org> port=6667 channel=#hackingsociety
>
>
>
>
> --
> Jeffrey Haemer <jeffrey.haemer at gmail.com
> <mailto:jeffrey.haemer at gmail.com>>
> 720-837-8908 [cell], http://seejeffrun.blogspot.com [blog],
> http://www.youtube.com/user/goyishekop [vlog]
> /????????? ??? ??? ????? ????? ??????./
>
>
> _______________________________________________
> Web Page: http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> Join us on IRC: irc.hackingsociety.org port=6667 channel=#hackingsociety
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lug.boulder.co.us/pipermail/lug/attachments/20121222/9d228a48/attachment.html>
More information about the LUG
mailing list