定时检测进程挂了,然后重启
一、准备脚本monitoring.sh
#!/bin/sh
ps -ef | grep "turnserver" | grep -v grep
#如果进程搜索不出来$?为1否则为0,当不为0的时候重启进程
if [ $? -ne 0 ]
then
./turn-run.sh
else
echo "running"
fi
如果端口不存在了, 则重启服务
二、添加定时任务
Linux crontab 命令
crontab -e
每分钟执行脚本文件
* * * * * /etc/profile;/bin/sh /usr/local/app/monitoring.sh
重启crond
service crond restart
查看当前系统登录用户的Crontab命令集合
crontab -l
