首页 > 解决方案 > Web服务器中的Logrotation

问题描述

我已经在我的一个网络服务器中设置了 logrotation,但它不适用于我在 /etc/logrotate.d/customfile 中的自定义要求。下面是 /etc 目录中的 logrotate.conf、logrotate.d/customfile 和 cron.daily。如何使其适用于 customfile 中的配置详细信息?

/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
        minsize 1M
    rotate 1
}

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

/etc/logrotate.d/customfile

"/app/logs/website.com/error_log" "/app/logs/website.com/access_log" {
   daily
   size 500M
   missingok
   rotate 30
   compress
   delaycompress
   nomail
   create 644 admin admin
   sharedscripts
   postrotate
      if [ -f /app/instance/sites/website.com/run/httpd.pid ]; then
         su - admin -c /app/instance/sites/website.com/gracefulApache.sh > /dev/null
      fi
   endscript
   }

/etc/cron.daily/logrotate

#!/bin/sh

/usr/sbin/logrotate -s /var/lib/logrotate/logrotate.status /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
    /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0

标签: linuxapachewebserverlogrotate

解决方案


推荐阅读