在Ubuntu上設置Filebeat定時任務,常用的是使用cron
或systemd
,以下是具體方法:
crontab -e
(若需root權限則用sudo crontab -e
)。0 2 * * * /usr/share/filebeat/filebeat -e -c /etc/filebeat/filebeat.yml
filebeat.timer
文件:sudo nano /etc/systemd/system/filebeat.timer
。[Unit]
Description=Run Filebeat every 5 minutes
[Timer]
OnBootSec=5min
OnUnitActiveSec=5min
Unit=filebeat.service
Persistent=true
[Install]
WantedBy=timers.target
sudo systemctl daemon-reload
。sudo systemctl start filebeat.timer
。sudo systemctl enable filebeat.timer
。