本文共 828 字,大约阅读时间需要 2 分钟。
下面是脚本:
#! /bin/bash## service-restart Automount system service in the specified direcotry.## chkconfig: 2345 90 10# description: 这个程序用来监控服务器服务软件,以程序挂掉后重启 Author is six 2020年12月1日15:40:45.# ! /bin/shLOG_FILE="/opt/xie/my-project/errorLog/restart.log"SERVICE_NAME="my-project"cd /opt/six/my-project/while true do project=`ps -ef|grep "my-project"|grep -v grep|wc -l` if [ $project -eq 0 ] then #echo "start tomcat..." echo `date +%Y-%m-%d` `date +%H:%M:%S` $SERVICE_NAME >>$LOG_FILE nohup java -jar my-project.jar > nohup.out 2>&1 & # else #echo "no start" fi sleep 60 #每60秒检查一轮done
脚本后台启动命令:nohup ./project.sh >/dev/null 2>&1 &
命令解释:
----------------------------------------------------------------------------------------------------------------------------------------------
转载地址:http://ayrqj.baihongyu.com/