shell脚本根据端口号自启动jar

#! /bin/bash

port=8093
pid=`lsof -t -i:$port`
echo "$pid"
if [ $pid eq 0 ]
then
	echo "api is already stopped"
else
	kill -9 $pid
	echo "api is killed"
fi
java -jar -Xms512m -Xmx512m -Xmn200m -Xss256k api-0.0.1-SNAPSHOT.jar --spring.profiles.active=prod &

  

原文地址:https://www.cnblogs.com/james-roger/p/14132041.html