1. 程式人生 > >查詢程序ID並且kill

查詢程序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