springboot项目后台启动,附送一键启动脚本

nohup java -jar xxxxxx.jar > catalina.out 2>&1 &

 

参数解释:

nohup        意思就是不挂断运行,没此参数挂断连接会停止程序

>contro_log.out   :意思就是将标准输出重定向到了 ./contro_log.out

2>&1        :意思就是将标准错误重定向到标准输出。这里标准输出已经重定向到了 ./contro_log.out ,那么标准错误也会输出到./contro_log.out

&          :后台运行

 

附上启动脚本代码:

#!/bin/sh
RESOURCE_NAME=xxxxxxx-2.1.2.jar
RESOURCE_LOCATION=/home
 
tpid=`ps -ef|grep $RESOURCE_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 $RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Kill Process!'
kill -9 $tpid
else
echo 'Stop Success!'
fi
 
tpid=`ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
    echo 'App is started'
else
    echo 'App is Stop'
fi
 
rm -f tpid

nohup java -Xms256m -Xmx256m -XX:PermSize=32m -XX:MaxPermSize=256m -jar $RESOURCE_LOCATION/$RESOURCE_NAME > catalina.out 2>&1 &
echo  Starting...

 

你可能感兴趣的:(linux)