为了方便维护×××服务器,当Tunnel不通信后,自动重启open***服务
(1)、创建文件名为ping.sh
touch /opt/script/ping.sh
vi /opt/script/ping.sh
#!/bin/sh
if ! ping -c 5 172.16.0.1 > /dev/null 2>&1
then
echo "The Open*** is down! Now try restarting!" | service open*** restart
fi
#----ping 172.16.0.1 五次,当返回值为空,会执行下面的命令,若不为空无操作
#----echo显示的信息随意写,同时在重启open***服务,可以替换成重启网卡等等~
(2)、将以上脚本做计划任务
crontab -e
*/1 * * * * cd /opt/script && /bin/sh -x ping.sh
#----每隔1分钟执行一次脚本
重启crond服务
service crond restart
完结~
转载于:https://blog.51cto.com/yanhuan/1275183