Linux
•
•
By Leo
Journalctl 進階技巧:高效過濾 Systemd 日誌
告別 grep /var/log/messages
Systemd 的 Journald 採用二進位儲存日誌,提供了強大的索引功能。
常用指令:
journalctl -u nginx --since "1 hour ago":只看 Nginx 最近一小時的 Log。journalctl -p err -b:查看本次開機後的所有 Error 等級訊息。journalctl -f:即時追蹤 (類似 tail -f)。
維護提示:Journald 預設可能會佔用大量磁碟空間。建議在 /etc/systemd/journald.conf 設定 SystemMaxUse=500M,避免 Log 吃光硬碟。