1)重启 脚本
restart.sh
#!/bin/sh
jar_name=$1
jar_active=$2
echo $jar_name
pid=$(ps -ef | grep $jar_name | grep -v grep | grep -v /bin/sh | awk '{ print $2 }')
echo $pid
if [ -z "$pid" ]
then
echo $jar_name Application is already stopped
else
echo kill $pid
kill -9 ${pid}
fi
echo Starting application
echo "nohup java -Xms256M -Xmx256M -XX:PermSize=64M -XX:MaxPermSize=128M -jar ${jar_name} --spring.profiles.active=${jar_active} >/dev/null 2>&1 &"
nohup java -Xms256M -Xmx256M -XX:PermSize=64M -XX:MaxPermSize=128M -jar ${jar_name} --spring.profiles.active=${jar_active} >/dev/null 2>&1 &
exit 0
2)赋予脚本可执行权限
chmod +x ./restart.sh
3)执行命令
./restart.sh /目录/目录/你的.jar dev