Logrotate 错误:未找到文件

Logrotate 错误:未找到文件

我们的一台服务器反复出现 Logrotate 错误消息。

/etc/cron.daily/logrotate:错误,未找到 /usr/local/Zend/apache2/logs/error_log 的文件

日志轮换对于应查看的文件夹正常运行。错误提到了未受监控的文件夹。

/var/log/apache2/*.log /var/log/apache2/*/*.log {
  daily
  rotate 50
  compress
  delaycompress
  missingok
  notifempty
  sharedscripts
  postrotate
        /usr/local/Zend/apache2/bin/apachectl graceful
  endscript
}

当我error_log在 apache 文件夹中进行 grep 时,我发现以下内容:

conf/extra/httpd-ssl.conf:错误日志“/usr/local/Zend/apache2/logs/error_log”
conf/extra/httpd-vhosts.conf:错误日志/www/phones/logs/error_log

httpd logrotate 脚本不监控这两个文件夹。我们不使用 SSL,因此那里没有日志。手机日志在那里,但目前尚未轮换。我已 grep 了 logrotate.d 文件夹,以查看是否有其他 logrotate 配置文件监控 apache 文件夹,但没有结果。

/etc/logrotate.conf 的内容如下

# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones
create

# use date as a suffix of the rotated file
dateext

# uncomment this if you want your log files compressed
#compress

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp and btmp -- we'll rotate them here
/var/log/wtmp {
    monthly
    create 0664 root utmp
    rotate 1
}

/var/log/btmp {
    missingok
    monthly
    create 0600 root utmp
    rotate 1
}

输出/usr/sbin/logrotate /etc/logrotate.conf -d

reading config file /etc/logrotate.conf
including /etc/logrotate.d
reading config file dirmngr
reading config info for /var/log/dirmngr/dirmngr.log 
reading config file fail2ban
reading config info for /var/log/fail2ban.log 
reading config file httpd
reading config info for /var/log/apache2/*.log /var/log/apache2/*/*.log 
reading config file ppp
reading config info for /var/log/ppp/connect-errors 
reading config file psacct
reading config info for /var/account/pacct 
reading config file rpm
reading config info for /var/log/rpmpkgs 
reading config file rsyslog
reading config info for /var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron 
reading config file snmpd
reading config info for /var/log/snmpd.log 
reading config file wpa_supplicant
reading config info for /var/log/wpa_supplicant.log 
reading config file yum
reading config info for /var/log/yum.log 
reading config info for /var/log/wtmp 
reading config info for /var/log/btmp 

Handling 12 logs

rotating pattern: /var/log/dirmngr/dirmngr.log  weekly (4 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/dirmngr/dirmngr.log
  log /var/log/dirmngr/dirmngr.log does not exist -- skipping

rotating pattern: /var/log/fail2ban.log  30720 bytes (4 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/fail2ban.log
  log does not need rotating
not running postrotate script, since no logs were rotated

rotating pattern: /var/log/apache2/*.log /var/log/apache2/*/*.log  after 1 days (50 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/apache2/access.log
  log does not need rotating
considering log /var/log/apache2/voip-access.log
  log does not need rotating
considering log /var/log/apache2/voip-error.log
  log does not need rotating
considering log /var/log/apache2/zoo-access.log
  log does not need rotating
considering log /var/log/apache2/zoo-error.log
  log does not need rotating
considering log /var/log/apache2/error.log
  log does not need rotating
considering log /var/log/apache2/trs_error.log
  log does not need rotating
considering log /var/log/apache2/market-access.log
  log does not need rotating
considering log /var/log/apache2/market-error.log
  log does not need rotating
considering log /var/log/apache2/shop/staging-access.log
  log does not need rotating
considering log /var/log/apache2/shop/staging-error.log
  log does not need rotating
considering log /var/log/apache2/shop/shop-access.log
  log does not need rotating
considering log /var/log/apache2/shop/shop-error.log
  log does not need rotating
not running postrotate script, since no logs were rotated

rotating pattern: /var/log/ppp/connect-errors  after 1 days (5 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/ppp/connect-errors
  log /var/log/ppp/connect-errors does not exist -- skipping

rotating pattern: /var/account/pacct  after 1 days (31 rotations)
empty log files are not rotated, old logs are removed
considering log /var/account/pacct
  log does not need rotating
not running postrotate script, since no logs were rotated

rotating pattern: /var/log/rpmpkgs  weekly (4 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/rpmpkgs
  log does not need rotating

rotating pattern: /var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron  weekly (4 rotations)
empty log files are rotated, old logs are removed
considering log /var/log/messages
  log does not need rotating
considering log /var/log/secure
  log does not need rotating
considering log /var/log/maillog
  log does not need rotating
considering log /var/log/spooler
  log does not need rotating
considering log /var/log/boot.log
  log does not need rotating
considering log /var/log/cron
  log does not need rotating
not running postrotate script, since no logs were rotated

rotating pattern: /var/log/snmpd.log  weekly (4 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/snmpd.log
  log /var/log/snmpd.log does not exist -- skipping
not running postrotate script, since no logs were rotated

rotating pattern: /var/log/wpa_supplicant.log  30720 bytes (4 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/wpa_supplicant.log
  log /var/log/wpa_supplicant.log does not exist -- skipping

rotating pattern: /var/log/yum.log  yearly (4 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/yum.log
  log does not need rotating

rotating pattern: /var/log/wtmp  monthly (1 rotations)
empty log files are rotated, old logs are removed
considering log /var/log/wtmp
  log does not need rotating

rotating pattern: /var/log/btmp  monthly (1 rotations)
empty log files are rotated, old logs are removed
considering log /var/log/btmp
  log /var/log/btmp does not exist -- skipping

是什么原因导致了这个错误?我不知道去哪里查找。

答案1

我从头开始讲:

  1. logrotate检查内部调用/etc/cron.daily/logrotate,看看是否使用了一些特殊的配置文件。传统上/etc/logrotate.conf是使用的。
  2. .conf文件中,查找include指令。您应该有一个:include /etc/logrotate.d并在此目录中查找error_log。另外,检查文件中没有声明系统特定的日志.conf

你有什么发现吗?

如果没有,我建议您运行logrotate里面的命令/etc/cron.daily/logrotate,并向-d其中添加开关。

相关内容