linux下啟動和終止JAVA程式shell指令碼

追極發表於2018-05-16

1.啟動指令碼start.sh

#run application backgroud
nohup java -jar chess-admin-1.0-SNAPSHOT.jar >/dev/null 2>&1 &
#record the process id
echo $!>pid

 

2.終止指令碼stop.sh

kill `cat pid`

 或者查詢pid後終止

kill `jps -l | grep chess-admin | awk `{print $1}``

 或

kill `jps -l |awk `$2~"chess-admin"{print $1}``

 

相關文章