port=8081 #根据端口号查询对应的pid pid=$(netstat -nlp | grep :$port | awk '{print $7}' | awk -F"/" '{ print $1 }'); #杀掉对应的进程,如果pid不存在,则不执行 if [ -n "$pid" ]; then kill -9 $pid; fi source /etc/profile nohup java -jar /root/jenkins/zhundian-operation/zhundian-operator-core/target/zhundian-operator-core.jar >/opt/logs/zhundian/zhundian-operation/catalina.out 2>&1 & sleep 20 tail -n 300 /opt/logs/zhundian/zhundian-operation/catalina.out exit 0