nohup启动filebeat会自动退出解决方案

2023-01-04  本文已影响0人  宇VS然

用nohup方式启动filebeat,运行一段时间后,filebeat会自动停止退出,因为filebeat默认会定期检测文件是否有新的内容。

解决办法:将filebeat通过系统后台的方式长期运行。

1,在进入 /etc/systemd/system目录,创建一个filebeat.service文件

filebeat.service

[Unit]

Description=Filebeat is a lightweight shipper for metrics.

Documentation=https://www.elastic.co/products/beats/filebeat

Wants=network-online.target

After=network-online.target

[Service]

Environment="LOG_OPTS=-e"

Environment="CONFIG_OPTS=-c /root/filebeat-7.17.8-linux-x86_64/filebeat.yml"

Environment="PATH_OPTS=-path.home /root/filebeat-7.17.8-linux-x86_64/filebeat -path.config /root/filebeat-7.17.8-linux-x86_64 -path.data //root/filebeat-7.17.8-linux-x86_64/data -path.logs /root/filebeat-7.17.8-linux-x86_64/logs"

ExecStart=/root/filebeat-7.17.8-linux-x86_64 $LOG_OPTS $CONFIG_OPTS $PATH_OPTS

Restart=always

[Install]

WantedBy=multi-user.target

将上面filebeat目录改成你的filebeat安装目录

2,给予可执行的权限

chmod +x /etc/systemd/system/filebeat.service

3,后台启动服务

systemctl daemon-reload

systemctl enable filebeat

systemctl start filebeat

上一篇 下一篇

猜你喜欢

热点阅读