注意第一行是bash,虚拟机中用的sh
里面的192.168.37.16可以改成其他的IP
#!/bin/bash
while :
do
ping -c 1 -w 3 192.168.37.16
if [ $? = 0 ];then
echo $(date) "ping successfully"
sleep 1
else
echo "ping error"
sleep 1
fi
done
注意第一行是bash,虚拟机中用的sh
里面的192.168.37.16可以改成其他的IP
#!/bin/bash
while :
do
ping -c 1 -w 3 192.168.37.16
if [ $? = 0 ];then
echo $(date) "ping successfully"
sleep 1
else
echo "ping error"
sleep 1
fi
done