码迷,mamicode.com
首页 > 系统相关 > 详细

Shell重启Tomcat脚本

时间:2018-09-24 13:52:37      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:shel   col   sof   more   pre   $2   else   cat   ram   

 

#!/bin/bash

echo -e "\n\n\n"

#force kill flag,if equal [f] to force kill all
flag="HelloShell"
if test $# -gt 0
then
    flag=$1
fi

pids=`ps -ef|grep tomcat | grep -v "grep" | awk {print $2}`
#pids=`ps -ef|grep -w tomcat | grep -v "grep" | awk {print $2}`

count=0
pid_num=0
for pid in ${pids}
do
    pid_num=${pid}
    count=`expr ${count} + 1`
done

if test $[count] -gt 1
then
    if test $flag = "f"
    then
        for pid in ${pids}
        do
            echo "kill " ${pid}
            kill -9 ${pid}
        done
        echo "Force kill more progress success!"
    else
        echo "Exist more progress is running, Input param [f] to force kill."
    fi
else
    if test $[count] -eq 1
    then
        kill -9 ${pid_num}
        echo "Kill " ${pid_num} " Success!"
    else
        echo "Clear!"
    fi
fi

# start
bash /root/soft/apache-tomcat-7.0.90/bin/startup.sh



echo -e "\n\n\n"

 

Shell重启Tomcat脚本

标签:shel   col   sof   more   pre   $2   else   cat   ram   

原文地址:https://www.cnblogs.com/jonban/p/9695264.html

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