RedHat SysV init and Systemd unit 编写示例

网友投稿 218 2022-10-01

RedHat SysV init and Systemd unit 编写示例

RedHat CentOS6 SysV init and CentOS7 Systemd unit CentOS6 SysV init sample

#!/bin/bash #chkconfig: 345 99 99 #description:node_exporter service and add /etc/rc.d/init.d directory #processname:node_exporter #desc:chkconfig --add node_exporter;execute service node_exporter start count="0" instance_path="/usr/local/bin/node_exporter" instance_path_arg="--web.disable-exporter-metrics" case $1 in start) ${instance_path} ${instance_path_arg} &>/dev/null & ;; stop) pkill -f ${instance_path} ;; status) count=$(ps -ef | grep "${instance_path} ${instance_path_arg}" | grep -v "grep" | wc -l) if [ $count -gt 0 ];then echo "[node_exporter] is running..." else echo "[node_exporter] is not running..." fi ;; esac

CentOS7 Systemd unit sample

# /usr/lib/systemd/system/mysqld_exporter.service # add mysqld_exporter.service to /usr/lib/systemd/system # execute systemctl daemon-reload # execute systemctl status|restart|start mysqld_exporter [Unit] Description=Mysqld Exporter Wants=network-online.target After=network-online.target [Service] User=root Group=root Type=simple Environment='DATA_SOURCE_NAME=hadoop-mysqld-exporter:hadoop-mysqld-exporter@(172.16.0.60:3306)/' ExecStart=/usr/local/bin/mysqld_exporter --web.disable-exporter-metrics --web.config=/path to others Restart=on-failure RestartForceExitStatus=16 RestartPreventExitStatus=1 StandardOutput=syslog StandardError=syslog [Install] WantedBy=multi-user.target

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:SpringBoot HttpMessageConverter消息转换器的使用详解
下一篇:Azure新知识科普 - Cross Region Load Balancer
相关文章

 发表评论

暂时没有评论,来抢沙发吧~