溫馨提示×

filebeat在ubuntu上的定時任務設置

小樊
39
2025-09-01 06:14:25
欄目: 智能運維

在Ubuntu上設置Filebeat定時任務,常用的是使用cronsystemd,以下是具體方法:

使用cron設置

  1. 打開終端,輸入crontab -e(若需root權限則用sudo crontab -e)。
  2. 在打開的文件中添加定時任務行,例如每天凌晨2點執行Filebeat:
0 2 * * * /usr/share/filebeat/filebeat -e -c /etc/filebeat/filebeat.yml
  1. 保存并關閉文件。

使用systemd設置

  1. 創建filebeat.timer文件:sudo nano /etc/systemd/system/filebeat.timer。
  2. 添加以下內容,這里設置每5分鐘運行一次:
[Unit]
Description=Run Filebeat every 5 minutes

[Timer]
OnBootSec=5min
OnUnitActiveSec=5min
Unit=filebeat.service
Persistent=true

[Install]
WantedBy=timers.target
  1. 重新加載systemd守護進程:sudo systemctl daemon-reload。
  2. 啟動定時器:sudo systemctl start filebeat.timer。
  3. 若要開機自啟,執行:sudo systemctl enable filebeat.timer。

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女