zabbix_server,zabbix_proxy启动,停止命令

本文详细介绍了如何使用`systemctl`命令管理Zabbix Server(启动、停止和查看状态),以及如何通过编辑启动配置文件来实现更精细的控制。还涵盖了如何通过ps命令检查进程状态,并提供了创建启动脚本进行自动化管理的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

常用的命令

systemctl status zabbix_server #查看状态

systemctl start zabbix_server #启动

systemctl stop zabbix_server #停用

======================

然后

ps -ef | grep zabbix_server

查看 zabbix_server 状态;

如果上述命令,不能 停用 ;则 尝试;下列 命令,停用 zabbix_server

ps -ef | grep zabbix_server | grep -v grep | awk '{print "kill -9 "$2}'|sh

linux 可以配置 启动配置文件

再 /etc/rc.d/init.d/ 路径下,创建  zabbix_server文件

并,把 下列复制进去

需要注意:BASEDIR=/opt/hello/zabbixsvr5, 的 填写  zabbix_server 的路径

#[root@sssss~]# cat /etc/rc.d/init.d/zabbix_server
#!/bin/bash
#
# chkconfig: - 90 10
# description:  Starts and stops Zabbix Server using chkconfig
#				Tested on Fedora Core 2 - 5
#				Should work on all Fedora Core versions
#
# @name:	zabbix_server
# @author:	Alexander Hagenah <hagenah@topconcepts.com>
# @created:	18.04.2006
#
# Modified for Zabbix 2.0.0
# May 2012, Zabbix SIA
#
# Source function library.
. /etc/init.d/functions

# Variables
# Edit these to match your system settings

	# Zabbix-Directory
	BASEDIR=/opt/hello/zabbixsvr5

	# Binary File
	BINARY_NAME=zabbix_server

	# Full Binary File Call
	FULLPATH=$BASEDIR/sbin/$BINARY_NAME

	# PID file
	PIDFILE=/tmp/$BINARY_NAME.pid

	# CONF file
        CONFFILE=$BASEDIR/etc/zabbix_server.conf

	# Establish args
	ERROR=0
	STOPPING=0

#
# No need to edit the things below
#

# application checking status
if [ -f $PIDFILE  ] && [ -s $PIDFILE ]
	then
	PID=`cat $PIDFILE`
	
	if [ "x$PID" != "x" ] && kill -0 $PID 2>/dev/null && [ $BINARY_NAME == `ps -e | grep $PID | awk '{print $4}'` ]
	then
		STATUS="$BINARY_NAME (pid `pidof $APP`) running.."
		RUNNING=1
	else
		rm -f $PIDFILE
		STATUS="$BINARY_NAME (pid file existed ($PID) and now removed) not running.."
		RUNNING=0
	fi
else
	if [ `ps -e | grep $BINARY_NAME | head -1 | awk '{ print $1 }'` ]
		then
		STATUS="$BINARY_NAME (pid `pidof $APP`, but no pid file) running.."
	else
		STATUS="$BINARY_NAME (no pid file) not running"
	fi
	RUNNING=0
fi

# functions
start() {
	if [ $RUNNING -eq 1 ]
		then
		echo "$0 $ARG: $BINARY_NAME (pid $PID) already running"
	else
		action $"Starting $BINARY_NAME: " $FULLPATH -c $CONFFILE
		touch /var/lock/subsys/$BINARY_NAME
    fi
}

stop() {
	echo -n $"Shutting down $BINARY_NAME: "
	killproc $BINARY_NAME
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$BINARY_NAME
	RUNNING=0
}


# logic
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	status)
		status $BINARY_NAME
		;;
	restart)
		stop
		sleep 10
		start
		;;
	help|*)
        echo $"Usage: $0 {start|stop|status|restart|help}"
		cat <<EOF

			start		- start $BINARY_NAME
			stop		- stop $BINARY_NAME
			status		- show current status of $BINARY_NAME
			restart		- restart $BINARY_NAME if running by sending a SIGHUP or start if not running
			help		- this screen

EOF
	exit 1
	;;
esac

exit 0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值