轮换 apache 日志文件

轮换 apache 日志文件

我想/var/log/httpd以这种方式旋转文件夹下的文件:

  1. 每周轮换日志文件

  2. 日志文件在被删除之前将轮换 5 次

所以我想将以下值添加到 /etc/logrotate.d/httpd文件中

weekly

rotate 5

请告知这是否是我旋转文件所需要的一切?当前配置不轮换日志。我的红帽机器版本 6.5 上的当前配置如下:

 # ls -ltr

   -rw-r--r-- 1 root root  1003 Aug  7 13:49 error_log
   -rw-r--r-- 1 root root   476 Aug  7 13:49 access_log
   -rw-r--r-- 1 root root   231 Aug  8 07:21 ssl_request_log
   -rw-r--r-- 1 root root   201 Aug  8 07:21 ssl_access_log



# chkconfig --list |grep cron
  crond           0:off   1:off   2:on    3:on    4:on    5:on    6:off

# /etc/init.d/crond status
  crond (pid  1528) is running...




# cat /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
}

# system-specific logs may be also be configured here.





cat /etc/logrotate.d/httpd
 /var/log/httpd/*log {
   missingok
   notifempty
   sharedscripts
   postrotate
      /sbin/service httpd reload > /dev/null 2>/dev/null || true
   endscript
 }

相关内容