/var/log/kern.log* 各文件说明
时间: 2023-09-28 18:10:07 浏览: 131
/var/log/kern.log* 包含了 Linux 内核相关的日志信息,其中:
- kern.log:记录了内核启动和停止信息,包括硬件检测、驱动加载、系统调用、中断等。
- kern.log.1:前一天的 kern.log。
- kern.log.2.gz:前两天的 kern.log,已经压缩。
- kern.log.3.gz:前三天的 kern.log,已经压缩。
- kern.log.4.gz:前四天的 kern.log,已经压缩。
这些日志文件通常用于故障排查和系统监控,可以通过查看日志文件了解系统的运行情况和问题。
相关问题
kern.log和syslog过大
如果你的 kern.log 和 syslog 文件过大,可以考虑进行以下操作:
1. 清除旧日志:使用命令 `sudo logrotate -f /etc/logrotate.conf` 可以清除旧的日志记录,只保留最近的记录。
2. 压缩日志文件:使用命令 `sudo gzip -9 /var/log/kern.log` 和 `sudo gzip -9 /var/log/syslog` 可以将日志文件压缩,减少磁盘占用空间。
3. 修改日志记录级别:在 /etc/rsyslog.conf 文件中,可以修改日志记录级别,例如将 debug 级别的日志记录改为 info 级别的日志记录,可以减少日志记录量。
4. 定期备份日志文件:将日志文件定期备份到其他存储设备上,可以避免磁盘空间不足的问题。
注意,修改日志记录级别可能会影响系统的调试和故障排查,所以在进行修改前请确保了解其影响。
请提供一份syslog.conf的配置模板,要求包含kern.warning、*.err、authpriv.none、@loghost*.info、mail.none、authpriv.none、cron.none、@loghost*.emerg、@loghostlocal7.*、@loghost
以下是一份符合要求的 syslog.conf 配置模板:
```bash
# Log all kernel warnings to the console and to the local7 facility on the remote loghost.
kern.warning /dev/console
kern.warning @loghostlocal7.*
# Log all messages with a priority of err or higher to the console and to the remote loghost.
*.err /dev/console
*.err @loghost
# Ignore messages from the authpriv facility from the local system and from the remote loghost.
authpriv.none /var/log/messages
authpriv.none @loghost
# Log all info messages to the local7 facility on the remote loghost and ignore mail messages from all sources.
*.info @loghost
mail.none /var/log/messages
# Ignore messages from the authpriv and cron facilities from all sources.
authpriv.none /var/log/messages
cron.none /var/log/messages
# Log all emergency messages to the local7 facility on the remote loghost and to the local system.
*.emerg @loghostlocal7.*
*.emerg /dev/console
# Log all messages from the local7 facility to the local system and to the remote loghost.
local7.* /var/log/local7.log
local7.* @loghost
```
该配置文件将内核警告记录到本地控制台和远程loghost服务器的local7设施中,将所有错误级别及以上的消息记录到本地控制台和远程loghost服务器,并将某些设施的消息记录到不同的文件中。它还指定了将某些消息发送到远程loghost服务器的方式。
请注意,具体的配置需根据您的实际需要进行修改。例如,您可能需要将某些设施的日志消息记录到不同的远程服务器或记录到不同的本地文件中。