Springboot核心技术SpringBoot之路SpringBoot极简教程 · Spring Boot

Springboot在linux启停

2017-10-14  本文已影响72人  老胡聊聊天

start.sh

#!/bin/sh

rm -f tpid

nohup java -jar /var/www/wowdata-0.0.1-SNAPSHOT.jar

echo $! > tpid

echo Start Success!

stop.sh

#!/bin/sh
APP_NAME=wowdata

tpid=`ps -ef|grep $APP_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 $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
    echo 'Kill Process!'
    kill -9 $tpid
else
    echo 'Stop Success!'
fi

check.sh

#!/bin/sh
APP_NAME=wowdata

tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
        echo 'App is running.'
else
        echo 'App is NOT running.'
fi

kill.sh

#!/bin/sh
APP_NAME=wowdata

tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
    echo 'Kill Process!'
    kill -9 $tpid
fi

给sh赋可执行权限

linux 下执行.sh文件提示permission denied
如果你是root登陆的话(不是的话,切换到root用户,对*.sh赋可执行的权限)

chmod 777 *.sh
 or
chmod +x  *.sh

然后运行就OK了

上一篇 下一篇

猜你喜欢

热点阅读