[lug] Scripting question

Jeffrey S. Haemer jeffrey.haemer at gmail.com
Thu Dec 20 20:46:23 MST 2012


I agree with Davide & Zan Lynx, of course.

Other stuff, if you still end up mystified:

(1) Capture the iptables output, with
  iptables -L -v | tee /tmp/iptables.OUT | grep INPUT | awk '{print $7}'
Just looking at the output of the iptables may do the trick.

(2) make things a little safer with
#!/bin/bash -eux
  instead of
#!/bin/sh

(3) Try putting this at the top of your crontab

SHELL=/bin/bash
BASH_ENV=~/.bashrc


On Thu, Dec 20, 2012 at 8:10 PM, Davide Del Vento <
davide.del.vento at gmail.com> wrote:

> I suspect the issue is that cron jobs do not get the same enviroment that
> a login shell does. You'll probably have to source the /etc/profile or
> something like that as first thing in the cron job. You might try
>
> env > env.txt
>
> both in login and in a cron job job and then diff'ing the difference.
>
> Happy Holidays to you too.
> Davide
>
>
> On Thu, Dec 20, 2012 at 8:04 PM, Paul Nowosielski <
> paulnowosielski at yahoo.com> wrote:
>
>> Dear All,
>>
>> I am trying to monitor bandwidth on a high traffic VPS web server
>> running CentOS 5.
>>
>> When I run the scripts from the command line it works perfectly and
>> gives an output like this:
>>
>> Fri Dec 21 02:40:12 CET 2012
>>
>> Bandwith out:
>> 274G
>>
>> Bandwidth in:
>> 85G
>>
>> When I run this as a cron job I get this:
>>
>> Fri Dec 21 03:00:01 CET 2012
>>
>> Bandwith out:
>>
>> Bandwidth in:
>>
>> As you can see I am not getting the output data when using cron and do
>> not understand why.
>>
>> Here is the commands I am running and the script I call:
>>
>> /bin/date >> /root/scripts/bandwTest; /root/scripts/bandwidth.sh >>
>> /root/scripts/bandwTest;
>>
>> bandwidth.sh
>>
>> cat scripts/bandwidth.sh
>>
>> #!/bin/sh
>>
>> echo
>> echo "Bandwith out:"
>> iptables -L -v |grep OUTPUT |awk '{print $7}'
>> echo
>> echo "Bandwidth in:"
>> iptables -L -v |grep INPUT |awk '{print $7}'
>> echo
>>
>> Could anyone on this list provide some insight into this?
>>
>> Thank you and happy holidays,
>>
>> Paul
>>
>>
>> _______________________________________________
>> 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
>>
>
>
> _______________________________________________
> 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
>



-- 
Jeffrey Haemer <jeffrey.haemer at gmail.com>
720-837-8908 [cell], http://seejeffrun.blogspot.com [blog],
http://www.youtube.com/user/goyishekop [vlog]
*פרייהייט? דאס איז יאַנג דינען וואָרט.*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lug.boulder.co.us/pipermail/lug/attachments/20121220/04b6bddc/attachment.html>


More information about the LUG mailing list