shell 脚本样例

# !/bin/bash

n=(1 2 3 4 5 6 )  

start(){  

        for i in ${n[*]}  

        do  

               nohup /mirror/kettle/./carte.sh 192.168.180.X 818${i} &  

        done

}  

stop(){  

        for i in ${n[*]}  

        do  

pid=`lsof -i :818${i} |grep -v 'grep' |  awk '{print $2}'`

                test "$pid" != "" && kill $pid && echo "Stop carte 818${i} Successful!" || echo "Stop carte$i Failed!"

        done  

}  

case "$1" in  

        start)  

                start;;  

        stop)  

                stop;;  

        restart)  

                stop  

                sleep 10  

                start;;  

        *)  

                echo "Usage: $0 {start|stop|restart}"  

esac  

exit 0  

转载于:https://my.oschina.net/kt431128/blog/224710

猜你喜欢

转载自blog.csdn.net/weixin_34326558/article/details/91952477