vim start.sh
和要运行的jar在同一目录下
#!/bin/sh 要运行的jar路径
RESOURCE_NAME=springcloud-eureka-0.0.1-SNAPSHOT.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
echo 'Kill Process!'
kill -9 $tpid
else
echo 'Stop Success!'
fi
tpid=`ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'App is running.'
else
echo 'App is NOT running.'
fi
rm -f tpid
nohup java -jar ./$RESOURCE_NAME --spring.profiles.active=test &
echo $! > tpid
echo Start Success!
给start.sh授权
chmod 777 start.sh
博客介绍了使用vim编辑start.sh脚本,且该脚本与要运行的jar在同一目录,同时说明了给start.sh脚本授权的操作,即使用chmod 777 start.sh命令。
1698

被折叠的 条评论
为什么被折叠?



