进程监控代码并实现启动
- 添加监控脚本
#!/bin/bash while true do #判断pid是否存在 pid=`ps -ef |grep "uniview"|grep -v grep` if [ $? -ne 0 ];then cd /home/soft nohup java -Duser.timezone=GMT+08 -jar ptg_uniview_vms_sdk-1.0.0-SNAPSHOT.jar -Xms=512M -Xmx=512M > uniview.log 2>&1 & echo "server uniview restart" timestanp=`date '+%Y-%m-%d %H:%M:%S'` echo "$timestanp - man 重启,请查看/home/soft/monitor.log" >>/home/soft/monitor.log sleep 5 else echo "uniview is normal" sleep 10 fi done
2.启动
nohup ./monitor.sh >/home/soft/monitor 2>&1 &
3.添加开机启动
vi /etc/rc.d/rc.local 中添加 /home/soft/monitor.sh
天地间,道大,人也大。人生本来就是上山、下山。而道心原本宽广,可容万物,装得下山河大地,万古星辰。

浙公网安备 33010602011771号