码迷,mamicode.com
首页 > 编程语言 > 详细

jar包重启脚本-restart.sh

时间:2019-01-22 20:40:54      阅读:521      评论:0      收藏:0      [点我收藏+]

标签:程序   div   print   roc   tar   .sh   重启   null   class   

#!/bin/sh
PROJECT_PATH=/var/www/
PROJECT_NAME=demo.jar
PROJECT_ALL_LOG_NAME=logs/demo-all.log
# stop process
tpid=`ps -ef|grep $PROJECT_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 $PROJECT_NAME|grep -v grep|grep -v kill|awk {print $2}`
if [ ${tpid} ]; then
    echo Kill Process!
    kill -9 $tpid
else
    echo Stop Success!
fi

# start process
tpid=`ps -ef|grep $PROJECT_NAME|grep -v grep|grep -v kill|awk {print $2}`
if [ ${tpid} ]; then
    echo App is already running.
else
    echo App is NOT running.

    nohup java -jar $PROJECT_PATH$PROJECT_NAME >/dev/null 2>&1 &
    echo Start Success!
    sleep 2
    tail -f $PROJECT_PATH$PROJECT_ALL_LOG_NAME
fi

 

jar包重启脚本-restart.sh

标签:程序   div   print   roc   tar   .sh   重启   null   class   

原文地址:https://www.cnblogs.com/qdwyg2013/p/10305833.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!