journalctl
查看系統日志(如journalctl -b
查看本次啟動日志);tail -f
實時查看大日志文件(如/var/log/messages
);grep
搜索關鍵字(如grep "error" /var/log/httpd/error_log
)。/var/log/messages
、/var/log/secure
。/var/log/httpd/access_log
(訪問日志)、/var/log/httpd/error_log
(錯誤日志)。/var/log/mysql/error.log
、/var/log/mysql/slow-query.log
(慢查詢日志)。/var/log/php-fpm.log
(若使用PHP-FPM)。使用logrotate
工具設置日志切割規則,如按大小或日期輪轉、保留天數、壓縮舊日志等,配置文件位于/etc/logrotate.d/
。
grep
、awk
等工具過濾關鍵信息。tail -f
或rsyslog
實時跟蹤日志。chmod
和chown
設置日志文件權限,僅授權人員可訪問。rsyslog
或syslog-ng
將日志發送至遠程服務器集中管理。