Springboot在linux启停

作者: 老胡聊聊天 | 来源:发表于2017-10-14 10:16 被阅读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了

    相关文章

      网友评论

        本文标题:Springboot在linux启停

        本文链接:https://www.haomeiwen.com/subject/mmkxuxtx.html