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 2>&1 & 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 -15 $tpid fi sleep 5 tpid=`ps -ef|grep $PROJECT_NAME|grep -v grep|grep -v kill|awk '{print $2}'` if [ ${tpid} ]; then echo 'Kill Process!' kill -9 $tpid else echo 'Stop Success!' fi
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/18582.html