停启服务打包解压的脚本

#!/bin/sh

serverArr=("server1" "server2")

#stop servers
for var in ${serverArr[@]}
do
    result=`ps x|grep java|grep ${var} |awk '{print $1}'`
    echo "The pid of ${var} is $result"
    kill $result

    typeset -i retryTimes=0

    while [[ $retryTimes -lt 100 ]]
    do
        sleep 5

        result=`ps -ef|grep ${var}|grep java|wc -l`
        if [ $result -eq 0 ]
        then
            echo "${var} has been successfully killed!"
        break
        fi
 
        retryTimes=$retryTimes+1
    done

    if [ $retryTimes -ge 100 ]
    then
        echo "Maximum retry times done. Abort stop ${var} ..."
        exit 1
    fi
done

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区