Translated message

A translation of this page exists in English.

Warning message

This translation is outdated. For the most up-to-date information, please refer to the English version.

当 logrotate 不能正常运行时,如何对 logrotate warnings 或者 logrotate errors 进行排错

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux (RHEL) 的所有版本

Issue

当 logrotate 不能正常运行时,如何对 logrotate warnings 或者 logrotate errors 进行排错

Resolution

检查 logrotate.status 文件

logrotate.status 文件中查看被 logrotate 的文件:

# cat /var/lib/logrotate.status

在debug模式下运行 logrotate

在 debug 模式下手动运行 logrotate 命令来查错:

# /usr/sbin/logrotate -d /etc/logrotate.conf

找到导致问题发生的配置文件

根据排错输出的报错,修复 /etc/logrotate.conf 的配置错误,/etc/logrotate.d/下配置文件的配置错误或者修复排错输出的其它错误。

在 debug 模式下重新运行 logrotate

# /usr/sbin/logrotate -d /etc/logrotate.conf

如果没有报错显示, 应该可以正常运行 logrotate

Root Cause

此例中, 丢失 /var/log/conman.old目录是问题发生的原因。 创建此目录会解决这个问题:

# mkdir /var/log/conman.old

Diagnostic Steps

有时在 /var/log/messsages 文件中会出现一些警告或报错。例如:

logrotate: ALERT exited abnormally with [1]

使用 logrotate 的参数 -d,开启 debug 模式。debug 模式不会改变 logs 或者 logrotate state file 。有需要的话,排错输出可以被重新导入到文件(e.g. /tmp/logrotate.debug)中, 可能对排错有所帮助:

# /usr/sbin/logrotate -d /etc/logrotate.conf 2> /tmp/logrotate.debug

排错输出的一个例子:

reading config file /etc/logrotate.conf
including /etc/logrotate.d
reading config file acpid
reading config info for /var/log/acpid 
reading config file conman
reading config info for /var/log/conman/* 
olddir is now /var/log/conman.old/
error: conman:21 error verifying olddir path /var/log/conman.old/: No such file or directory

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments