Springbootはlinuxで停止します

1244 ワード

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