shell脚本-ping监听任务

监控服务器ip是否在线:

#!/bin/bash
for((;;))
	do
#$1 输入ip
		ping -c1 $1 &>/opt/sleep.txt
		if [ $? -eq 0 ]
			then
				echo -e "`date +"%F %H:%M:%S"` : $1 is \033[32m UP \033[0m"
				sleep 600
		else
				echo -e "`date +"%F %H:%M:%S"` : $1 is \033[31m Down \033[0m"
				echo -e "\a"
				sleep 60
		fi
done

猜你喜欢

转载自blog.csdn.net/Batac_Lee/article/details/109705967