1、编辑一个脚本
vi /usr/local/watchicomet.sh
#!/bin/bash sn=`ps -ef | grep ./icomet-server | grep -v grep |awk '{print $2}'` echo $sn if [ "${sn}" = "" ] #如果为空,表示进程未启动 then nohup service icomet start > icomet.log 2>&1 & #后台启动进程 echo start icomet success! else echo icomet is running! fi
2、给上执行权限
chmod +x watchicomet.sh
3、设置每1分钟检查一次
echo "*/1 * * * * root /usr/local/watchicomet.sh > /dev/null 2>&1">>/etc/crontab