I wrote a shell script to poll network. It works fine from command line, but doesn't want to work from cron.
To clarify the problem, I wrote simple test file (test.ksh):
ping -c1 -q 172.27.38.2 > /path/res.log
when I do:
>ksh test.ksh
it works fine, and res.log populated with ping info.
but when I'm calling it from cron:
29 15 * * * ksh /path/test.ksh
it creates res.log with 0 size and that's it.
Why doesn't it work from cron?
This is how we ping other boxes to ensure their up and running.
Nb: This is run on a SCO Unix box.
Script:
# more /usr/users/operator/check_rcmd
if [ `rcmd $1 hostname | grep someweb.com` ]
then
echo OK
else
mailx -s "Unable to access SomeWeb server $1" ops@somedomain.com <<END
`hostname` cannot perform remote commands on $1
This may effect the ability to do bookings on $1
Follow TVL escalation procedure to resolve
END
fi
#
From Cron:
# Check rcmd is availble. Test for situation where corruption of the
# authorisation database was preventing remote access
10,40 * * * * /usr/users/operator/check_rcmd 168.153.251.80 > /dev/null 2>&1