第一次使用linux启动springboot的jar包,想写个shell脚本,网上的大都不详细,谁有详细步骤
RESOURCE_NAME=/xxx.jar
tpid=ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'
if [ ${tpid} ]; then
echo 'Stop Process...'
kill -15 $tpid
fi
sleep 5
tpid=ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'
if [ ${tpid} ]; then
kill -9 $tpid
else
echo 'Stop Success!'
fi
rm -f tpid
nohup java -Dfile.encoding=utf-8 -jar /xxx/xxx/$RESOURCE_NAME >/dev/null 2>&1 --spring.profiles.active=prod &
echo $! > tpid
echo Start Success!