首页 > 服务器    日期:2020-12-02 / 来自互联网 / 浏览

请根据自己实际路径修改第二行路径即可

#!/bin/bash
pfurl='/usr/local/sbin/zabbix_agentd -c /usr/local/etc/zabbix_agentd.conf'
PID=0
kill_zabbix_agentd(){
       ps aux | awk -r '/zabbix_agentd/{print $2}' | xargs -n1 -exec kill {} &> /dev/null
}
pfstart(){
        num=`ps aux | awk -r '/zabbix_agentd/{print $2}' | wc -l`
        if [ $num != "1" ];then
                echo "zabbix_agentd is useing"
        else
                echo "zabbix_agentd is starting..."
                $pfurl
                echo "start done!"
        fi
}

if [ "$1" == "-s" ];then
        if [ "$2" == "stop" ];then
                echo "zabbix_agentd is stopping...."
                kill_zabbix_agentd
                echo "stop done!"
        elif [ "$2" == "start" ];then
                pfstart
        elif [ "$2" == "restart" ];then
                echo "zabbix_agentd is stopping...."
                kill_zabbix_agentd
                echo "stop done!"       
                echo "zabbix_agentd is starting..."
                $pfurl
                echo "start done!"
        fi
elif [ "$1" == "--help" ];then
        echo "zabbix_agentd -s [start/stop/restart]"
else
        pfstart
fi

觉得上面的内容有用吗?快来点个赞吧!

点赞() 我要打赏

温馨提示 : 本站内容来自会员投稿以及互联网,所有源码及教程均为作者总结编辑,请大家在使用过程中提前做好备份,以免发生无法预知的错误,源码类教程请勿直接用于生产环境!

 可能感兴趣的文章