httpd服务脚本
[root@zabbix init.d]# cat httpd
#/bin/bash
# chkconfig: 2345 20 80
# description:
case $1 in
'start')
/usr/local/apache/bin/apachectl start
;;
'stop')
/usr/local/apache/bin/apachectl stop
;;
'restart')
/usr/local/apache/bin/apachectl restart
;;
*)
echo "Usage:service httpd start|stop|restart"
;;
esac
zabbix_server启动脚本
[root@zabbix init.d]# cat zabbix_server
#/bin/bash
# chkconfig: 2345 21 79
# description:
function stop(){
ps -ef|grep -Ev "grep|$0"|grep 'zabbix_server'|awk '{print $2}' |xargs kill -9
}
case $1 in
'start')
/usr/local/sbin/zabbix_server
;;
'stop')
stop
;;
'restart')
stop
/usr/local/sbin/zabbix_server
;;
*)
echo "Usage:service zabbix_server start|stop|restart"
;;
esac
zabbix_agentd启动脚本
[root@zabbix init.d]# cat zabbix_agentd
#/bin/bash
# chkconfig: 2345 22 78
# description:
function stop(){
ps -ef|grep -Ev "grep|$0"|grep 'zabbix_agentd'|awk '{print $2}' |xargs kill -9
}
case $1 in
'start')
/usr/local/sbin/zabbix_agentd
;;
'stop')
stop
;;
'restart')
stop
/usr/local/sbin/zabbix_agentd
;;
*)
echo "Usage:service zabbix_agentd start|stop|restart"
;;
esac
设置开机自动启动
[root@zabbix scripts]# vim httpd.sh
[root@zabbix scripts]# vim zabbix_agentd.sh
[root@zabbix scripts]# vim zabbix_server.sh
[root@zabbix scripts]# chkconfig --add httpd
[root@zabbix scripts]# chkconfig --add mysqld
[root@zabbix scripts]# chkconfig --add php-fpm
[root@zabbix scripts]# chkconfig --add zabbix_server
[root@zabbix scripts]# chkconfig --add zabbix_agentd
[root@zabbix scripts]# chkconfig --list
注:该输出结果只显示 SysV 服务,并不包含
原生 systemd 服务。SysV 配置数据
可能被原生 systemd 配置覆盖。
要列出 systemd 服务,请执行 'systemctl list-unit-files'。
查看在具体 target 启用的服务请执行
'systemctl list-dependencies [target]'。
httpd 0:关 1:关 2:开 3:开 4:开 5:开 6:关
mysqld 0:关 1:关 2:开 3:开 4:开 5:开 6:关
netconsole 0:关 1:关 2:关 3:关 4:关 5:关 6:关
network 0:关 1:关 2:开 3:开 4:开 5:开 6:关
php-fpm 0:关 1:关 2:开 3:开 4:开 5:开 6:关
rhnsd 0:关 1:关 2:开 3:开 4:开 5:开 6:关
zabbix_agentd 0:关 1:关 2:开 3:开 4:开 5:开 6:关
zabbix_server 0:关 1:关 2:开 3:开 4:开 5:开 6:关
在agent端只用自动启动zabbix-server