linux systemctl 配置启动程序

本文已filebeat 为例子

	
cd /usr/lib/systemd/system


touch filebeat.service


vim filebeat.service

filebeat.service 中输入如下内容

[Unit]
Description=filebeat server daemon
Documentation=/data/apps/filebeat-7.16.3-linux-arm64/filebeat -help
Wants=network-online.target
After=network-online.target
 
[Service]
User=root
Group=root
Environment="BEAT_CONFIG_OPTS=-c /data/apps/filebeat-7.16.3-linux-arm64/filebeat.yml"
ExecStart=/data/apps/filebeat-7.16.3-linux-arm64/filebeat $BEAT_CONFIG_OPTS
Restart=always
 
[Install]
WantedBy=multi-user.target

启动即可

#加载所有的服务
systemctl daemon-reload

#启动
systemctl start filebeat

#查看状态
systemctl status filebeat


#开机启动
systemctl enable filebeat


版权声明:本文为weixin_42710740原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。