[lug] Scripting question

Davide Del Vento davide.del.vento at gmail.com
Thu Dec 20 20:10:30 MST 2012


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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lug.boulder.co.us/pipermail/lug/attachments/20121220/f4a03262/attachment.html>


More information about the LUG mailing list