- 论坛徽章:
- 0
|
写了好久都不对请给为大侠帮忙
我要实现的功能很简单,主机A去ping 10.0.0.11和10.0.0.12如果两个都ping不通就4分钟后关机,如果在这4分钟有一个可以ping通就执行/sbin/shutdown -c 让不要关机.
#/bin/sh
#shutdown=false
status0=1
status1=1
while true
do
if ping 10.0.0.11 -c 1 -w 1 > /dev/null 2>&1 ; then
/sbin/shutdown -c
status0=0
fi
if ping 10.0.0.12 -c 1 -w 1 > /dev/null 2>&1 ; then
/sbin/shutdown -c
status1=0
fi
if [ $status0 = 0 -o $status1 = 0 ] ; then
/sbin/shutdown -c
# shutdown=false
else
echo "shouasasas"
/sbin/shutdown -h 4 &
echo "shoutdown" date > pinglog.log
# shutdown=fals
fi
sleep 5
done |
|