首页  :: 新随笔  :: 管理

linux 持续构建(自动部署) 重启动tomcat或进程的脚本

Posted on 2016-09-25 23:39  季枫  阅读(391)  评论(0编辑  收藏  举报
#!/bin/sh
TOMCAT_PATH=`dirname "$0"`

echo "TOMCAT_PATH is /usr/local/tomcat"

PID=`ps aux | grep /usr/local/tomcat | grep java | awk '{print $2}'`

if [ -n "$PID" ]; then
        echo "Will kill tomcat: $PID"
        sh "/usr/local/tomcat/bin/shutdown.sh"
        sleep 6
else echo "No Tomcat Process $PID"
fi

PID=`ps aux | grep /usr/local/tomcat | grep java | awk '{print $2}'`

while [ -n "$PID" ]; do
        kill  $PID && sleep 1
        echo "Try to kill $PID"
done

sh "/usr/local/tomcat/bin/startup.sh"
sleep 3

PID=`ps aux | grep /usr/local/tomcat | grep java | awk '{print $2}'`
if [ -n "$PID" ]; then
        echo "\nRestart tomcat successfully!"
else
        echo "\nFail to startup tomcat"
        exit 1
fi
/usr/local/tomcat你要替换的内容
智读 | 成都会领科技有限公司官网 | 智读App下载 | 每天听本书的博客 | |