linux 检测程序挂掉自动重启
脚本
#/bin/bash
while :
do
#jar包名
run=$(ps -ef |grep "auth.jar" |grep -v "grep")
if [ "$run" ] ; then
echo "服务正常!"
else
echo "服务关闭了!"
echo "启动服务中..."
#启动脚本 以及启动命令 如果没有脚本可以 nohup java -jar jar名
/cap/auth.sh start
echo "启动完成!"
fi
#每十秒轮询一次
sleep 10
done
授权脚本,后台执行
chmod a+x start.sh
nohup ./start.sh & 挂起当前脚本
或者nohup sh start.sh &