logwatch命令 – 遍历系统日志

aiofo2022-08-10  169

logwatch命令是一个可定制和可插入式的日志监视系统,它通过遍历给定时间范围内的系统日志文件而产生日志报告。logwatch默认每天执行一次,可以从/etc/cron.daily里看到。

语法格式:logwatch [参数]

常用参数:

--detail 指定日志报告的详细程度
--range 指定处理日志的日期范围

参考实例

只看sshd的日志情况:

[root@linuxcool ~]# logwatch --service sshd --detail High

查看sshd当天的日志情况:

[root@linuxcool ~]# logwatch --service sshd --detail High --range today

查看sshd昨天的日志情况:

[root@linuxcool ~]# logwatch --service sshd --detail High --range yesterday

查看sshd从2018年10月24日到2019年10月24日的日志情况:

[root@linuxcool ~]# logwatch --service sshd --detail High --range 'between 10/24/2018 and 10/24/2019'
转载请注明原文地址:https://www.aiofo.com/read-1133.html