springboot jar 后台运行 sh

本文通过创建.sh文件启动jar,并在后台运行。

假如需要运行的jar为

business-callpush-1.1.jar,系统linux centos6.9

1、新建一个文件夹callpush 

2、在callpush上新建bin目录

3、将business-callpush-1.1.jar移到bin下

4、在callpush目录下创建软连接

 ln -s bin/business-callpush-1.1.jar callpush


5、callpush下创建start.sh  stop.sh

start.sh:内容如下


#!/bin/sh

rm -f tpid

nohup java -jar callpush  &

echo $! > tpid

echo Start Success!

stop.sh内容如下:

#!/bin/sh

APP_NAME=callpush

tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`

if [ ${tpid} ]; then

    echo 'Stop Process...'

    kill -15 $tpid

fi

sleep 5

tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`

if [ ${tpid} ]; then

    echo 'Kill Process!'

    kill -9 $tpid

else

    echo 'Stop Success!'

fi

6、改变start.sh stop.sh属性  为可执行   chmod 770  start.sh   chmod 770  stop.sh
7、运行start.sh启动

8、运行stop.sh停止


转载:https://blog.csdn.net/luckyzsion/article/details/77867192 
 

猜你喜欢

转载自blog.csdn.net/yjh314/article/details/83541955