19,612
社区成员
发帖
与我相关
我的任务
分享
ps -ef | grep "[t]omcat" || /tomcat/bin/startup.sh
ps -ef | grep "你要监控的进程名字" || echo 重新启动
[/quote]
这个命令会把本身grep的这个进程给显示出来 所以不会say 重新启动
ps -ef | grep "你要监控的进程名字" | grep -v grep || 启动你的进程
time=0
ret=0
while[ 1 ]
do
./yourfile
ret=$?
let "time=time+1"
echo "ret=${ret}, time=${time}"
done
ps -ef | grep "你要监控的进程名字" || echo 重新启动