* weird script behaviour
@ 2003-05-23 12:48 urgrue
2003-05-23 13:34 ` Jamie Harris
0 siblings, 1 reply; 3+ messages in thread
From: urgrue @ 2003-05-23 12:48 UTC (permalink / raw)
To: linux-admin
i have script that runs ok from the prompt but doesnt run ok at all
from cron (yes we've all seen this before, but this time its weirder
than usually).
i even tried running it with env -i , but i cant reproduce the problem
at the shell - it only appears when started from cron.
the problem also does NOT appear when started with "at".
i snipped the script down to a bare test minimum and am still able to
reproduce the error, here it is:
#!/bin/bash
while true
do
sleep 1
echo "start" | logger
ping -n -c 1 -w 3 10.155.11.37 && continue
echo "we didnt continue..... | logger
done
point is to spot if a ping doesnt go.
run from the prompt, it works fine - it pings every second and i never
get to the "we didnt continue" part.
run from cron, it may or may not run ok for a little while (a minute or
so), but then it starts to repeatedly reach the "we didnt continue"
part - and itll keep hitting that part over and over again until i
intervene.
with a little extra checking, i found out that the ping isn't returning
zero (as it does from the shell), but its returning 141! where does
this come from? why does it only start appearing after a minute or so?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: weird script behaviour
2003-05-23 12:48 urgrue
@ 2003-05-23 13:34 ` Jamie Harris
0 siblings, 0 replies; 3+ messages in thread
From: Jamie Harris @ 2003-05-23 13:34 UTC (permalink / raw)
To: urgrue; +Cc: linux-admin
How frequently does cron attempt to run the script? Is there anything
between your and the destination that might not like a lot of pings
comming from/going to the same IP (because the script is running multiple
times) so it adapting its firewall to block you?
Seems unlikely but just a thought.
Jamie...
> i have script that runs ok from the prompt but doesnt run ok at all
> from cron (yes we've all seen this before, but this time its weirder
> than usually).
> i even tried running it with env -i , but i cant reproduce the problem
> at the shell - it only appears when started from cron.
> the problem also does NOT appear when started with "at".
> i snipped the script down to a bare test minimum and am still able to
> reproduce the error, here it is:
>
> #!/bin/bash
>
> while true
> do
> sleep 1
> echo "start" | logger
> ping -n -c 1 -w 3 10.155.11.37 && continue
> echo "we didnt continue..... | logger
> done
>
> point is to spot if a ping doesnt go.
> run from the prompt, it works fine - it pings every second and i never
> get to the "we didnt continue" part.
> run from cron, it may or may not run ok for a little while (a minute or
> so), but then it starts to repeatedly reach the "we didnt continue"
> part - and itll keep hitting that part over and over again until i
> intervene.
> with a little extra checking, i found out that the ping isn't returning
> zero (as it does from the shell), but its returning 141! where does
> this come from? why does it only start appearing after a minute or so?
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-admin" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
** This message was transmitted on 100% recycled electrons **
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: weird script behaviour
@ 2003-05-23 14:26 pacho baratta
0 siblings, 0 replies; 3+ messages in thread
From: pacho baratta @ 2003-05-23 14:26 UTC (permalink / raw)
To: linux-admin
Il ven, 2003-05-23 alle 14:48, urgrue ha scritto:
> i have script that runs ok from the prompt but doesnt run ok at all
> from cron (yes we've all seen this before, but this time its weirder
> than usually).
> i even tried running it with env -i , but i cant reproduce the problem
> at the shell - it only appears when started from cron.
> the problem also does NOT appear when started with "at".
> i snipped the script down to a bare test minimum and am still able to
> reproduce the error, here it is:
>
> #!/bin/bash
>
> while true
> do
> sleep 1
> echo "start" | logger
> ping -n -c 1 -w 3 10.155.11.37 && continue
> echo "we didnt continue..... | logger
> done
>
> point is to spot if a ping doesnt go.
> run from the prompt, it works fine - it pings every second and i never
> get to the "we didnt continue" part.
> run from cron, it may or may not run ok for a little while (a minute
or
> so), but then it starts to repeatedly reach the "we didnt continue"
> part - and itll keep hitting that part over and over again until i
> intervene.
> with a little extra checking, i found out that the ping isn't
returning
> zero (as it does from the shell), but its returning 141! where does
> this come from? why does it only start appearing after a minute or so?
the script is not good here's the prob.
u say
echo "we didnt continue..... | logger
without an "if...then" it's always true, so u always do echo "we
didn't..."
i'd better wrie so:
#!/bin/sh
while true
do
sleep 1
echo "start" | logger
if ping -n -c 1 -w 3 10.155.11.37
then echo "ping works and host is up, man!!" | logger
else echo "ping what?? is network up? is that host up??" | logger
fi
done
regards, pacho
--
pacho baratta IT Consultant
tel. +39 347 078.51.31 www.evolinux.it
mail: pachox@evolinux.it
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-05-23 14:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-23 14:26 weird script behaviour pacho baratta
-- strict thread matches above, loose matches on Subject: below --
2003-05-23 12:48 urgrue
2003-05-23 13:34 ` Jamie Harris
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).