1、编辑一个脚本
vi /usr/local/watchicomet.sh
#!/bin/bashsn=`ps -ef | grep ./icomet-server | grep -v grep |awk '{print $2}'`echo $snif [ "${sn}" = "" ] #如果为空,表示进程未启动thennohup 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