linux 创建 service

#!/bin/bash
# 安装 node_exporter 服务
# 在 centos 上测试通过
mkdir -p /usr/local/devops/exporter
cd /usr/local/devops/exporter
# wget https://netdisk-1253388903.cos.ap-beijing.myqcloud.com/node_exporter
wget https://res.stu77.cn/webdav/node_exporter
chmod +x node_exporter

 # 这里修改成你的用户
cat <<EOF >/etc/systemd/system/node_exporter.service
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target
 
[Service]
User=root 
# 通过 WorkingDirectory 指定工作目录
WorkingDirectory="asdfasdfasd" ExecStart=/usr/local/devops/exporter/node_exporter [Install] WantedBy=default.target EOF # 刷新 systemctl systemctl daemon-reload # 启用自动启动服务 systemctl enable node_exporter # 启动服务 systemctl start node_exporter

 

上一篇:Elasticsearch_exporter 监控指标


下一篇:普罗米修斯和BMC的对比_2021-08-01