Centos7 添加命令做系统服务
1、在/usr/lib/systemd/system/创建xxx.service,其中xxx是服务名,如/usr/lib/systemd/system/node_exporter.service
vim /usr/lib/systemd/system/node_exporter.service [Unit] Description=node_exporter After=network.target [Service] #Type=forking #如果启动进程是后台进程则需要开启这个 ExecStart=/usr/local/node_exporter/node_exporter Restart=on-failure WorkingDirectory=/usr/local/node_exporter/ StandardOutput=/var/log/node_exporter_output.log StandardError=/var/log/node_exporter_error.log [Install] WantedBy=multi-user.target
其中Description和ExecStart需要修改
2、启动
systemctl daemon-reload
systemctl satrt node_exporter