Linux開始プロセス終了プロセス共通コード

4369 ワード


linux springbootプロジェクトの起動
 
start.sh
#!/bin/sh

rm -f tpid

nohup java -jar restDate-0.0.1-SNAPSHOT.jar --spring.profiles.active=dev > /dev/null 2>&1 &

echo $! > tpid

echo Start Success!

 
stop.sh
#!/bin/sh
APP_NAME=restDate-0.0.1-SNAPSHOT

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

 
 
kill.sh
#!/bin/sh
APP_NAME=restDate-0.0.1-SNAPSHOT

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

 
修正に注意
APP_NAME

 
転載先:https://www.cnblogs.com/Leechg/p/10272015.html