定时PING 检查网络脚本

ping.sh

 

 

#!/bin/sh
pingcmd()
{
d=`date`
prefix="SERVER $1 PING $2"
ping -w 1 -c 1 $2>/dev/null
ret=$?
if [ $ret -eq 0 ]
then printf "[$d] $prefix\t OK\n"
else printf "[$d] $prefix\t ERROR\n"
fi
return 0
}

server0="10.20.0.101"
server1="10.20.0.101"
server2="10.20.0.102"
server3="10.20.0.103"
server4="10.20.0.104"

while true 
do
pingcmd $server0 $server1
pingcmd $server0 $server2
pingcmd $server0 $server3
pingcmd $server0 $server4

sleep 10

done

echo "exit"

 

你可能感兴趣的:(C++,c,脚本,C#)