阅读量:1
在Ubuntu上设置Filebeat定时任务,常用的是使用cron或systemd,以下是具体方法:
使用cron设置
- 打开终端,输入
crontab -e(若需root权限则用sudo crontab -e)。 - 在打开的文件中添加定时任务行,例如每天凌晨2点执行Filebeat:
0 2 * * * /usr/share/filebeat/filebeat -e -c /etc/filebeat/filebeat.yml
- 保存并关闭文件。
使用systemd设置
- 创建
filebeat.timer文件:sudo nano /etc/systemd/system/filebeat.timer。 - 添加以下内容,这里设置每5分钟运行一次:
[Unit]
Description=Run Filebeat every 5 minutes
[Timer]
OnBootSec=5min
OnUnitActiveSec=5min
Unit=filebeat.service
Persistent=true
[Install]
WantedBy=timers.target
- 重新加载systemd守护进程:
sudo systemctl daemon-reload。 - 启动定时器:
sudo systemctl start filebeat.timer。 - 若要开机自启,执行:
sudo systemctl enable filebeat.timer。
以上就是关于“filebeat在ubuntu上的定时任务设置”的相关介绍,筋斗云是国内较早的云主机应用的服务商,拥有10余年行业经验,提供丰富的云服务器、租用服务器等相关产品服务。云服务器资源弹性伸缩,主机vCPU、内存性能强悍、超高I/O速度、故障秒级恢复;电子化备案,提交快速,专业团队7×24小时服务支持!
简单好用、高性价比云服务器租用链接:https://www.jindouyun.cn/product/cvm