Linux下启动停止服务shell脚本

jenkins构建重新部署时脚本:

#!/bin/bash

app=auth

jar_pid=`ps -ef|grep -v grep | grep ‘java -jar e-$app-controller-1.0-SNAPSHOT.jar‘|awk ‘{ print $2 }‘`
echo $jar_pid
if [ ! -n "$jar_pid" ]; then
echo ‘will redeploy.‘

#rm -rf nohup.out
nohup java -jar e-$app-controller-1.0-SNAPSHOT.jar >>$app.log 2>&1 &
echo ‘redeploy success-001.‘
else
kill -9 $jar_pid
echo ‘kill‘ $jar_pid

nohup java -jar e-$app-controller-1.0-SNAPSHOT.jar >>$app.log 2>&1 &
echo ‘redeploy success-002.‘
fi

相关推荐