linux启动jar包(查询进程ID并且kill)

#!/bin/sh

count=$(netstat -nl | grep -w 8099 | sed -r 's#.* (.*)/.*#\1#'| wc -l)

if [ 0 == $count ];
then
   nohup java -jar /aaa.jar --spring.config.location=/aaa/application.yml >/aaa/nohup.out &
   tail -f nohup.out
else
   kill -9 $(ps -ef | grep order|grep -v grep | awk '{print $2}')

   nohup java -jar /aaa.jar --spring.config.location=/aaa/application.yml >/aaa/nohup.out &

   tail -f nohup.out
fi

你可能感兴趣的:(linux)