LOG_FILE=/start/jenkins.log #需要修改 1.启动日志文件
APP_NAME=jenkins #需要修改 2.应用名称
pid=`ps -ef | grep $APP_NAME | grep -v grep | tr -s " "|cut -d" " -f2 `
start(){
if [ -n "$pid" ];then
echo -e "$APP_NAME is already running (pid: $pid)"
else
echo -e "start $APP_NAME ...."
nohup java -jar /usr/lib/jenkins/jenkins.war --httpPort=8083 > $LOG_FILE 2>&1 & #需要修改3.启动命令
fi
}
status(){
if [ -n "$pid" ];then
echo -e "$APP_NAME is running with pid:$pid"
else
echo -e "$APP_NAME not running"
fi
}
stop(){
if [ -n "$pid" ];then
kill -9 $pid
echo -e "$APP_NAME is stoped"
else
echo -3 "$APP_NAME not running"
fi
}
case $1 in
start)
start;;
stop)
stop;;
restart)
stop
start;;
status)
status;;
*)
echo 'Usage: $0 {start,stop,status,restart}'
;;
esac
exit 0