1.前台启动:(ctrl+c会关闭程序)

  java -jar    ****.jar

2.后台启动:(& 后台启动)

  java -jar    ****.jar &

3.控制台输出启动:

  java -jar    ****.jar  > catalina.out  2>&1 &

    catalina.out将控制台信息输出到catalina.out

    2>&1 输出所有的日志文件

    & 后台启动

4.脚本启动:

#!/bin/sh

rm -f tpid

nohup java -jar xxx.jar --spring.profiles.active=dev >catalina.out >& &

echo $! > tpid

echo Start Success!

  停止:

#!/bin/sh
PROJECT_NAME=jar包名称 tpid=`ps -ef|grep $PROJECT_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Stop Process...'
kill - $tpid
fi
sleep
tpid=`ps -ef|grep $PROJECT_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Kill Process!'
kill - $tpid
else
echo 'Stop Success!'
fi
05-11 08:36