Shell脚本启动/停止/重启(SpringBoot)jar包

1、启动startup.sh

nohup java -jar demo-0.0.1-SNAPSHOT.jar &
tail -f nohup.out

2、停止stop.sh

#!/bin/bash
pid=`ps -ef |grep demo-0.0.1-SNAPSHOT.jar | grep -v grep | awk '{print $2}'`
b=0
if [ $pid -gt $b ]
then
kill -9 $pid
echo "demo has stopped!"
else
echo "demo is not running!"
fi

3、重启

sh startup.sh

sh stop.sh

你可能感兴趣的:(系统运维)