加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Shell重启Tomcat脚本

发布时间:2020-12-15 23:26:24 所属栏目:安全 来源:网络整理
导读:? #!/bin/ bashecho -e " nnn " #force kill flag, if equal [f] to force kill allflag = " HelloShell " if test $# -gt 0 then flag =$ 1 fipids =`ps -ef|grep tomcat | grep -v " grep " | awk ‘ {print $2} ‘ `#pids =`ps -ef|grep -w tomcat | g

?

#!/bin/bash

echo -e "nnn"

#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 "nnn"

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读