Apacheログファイルの回転

Apacheログファイルの回転

/var/log/httpd次のようにフォルダの下のファイルを回転させたいと思います。

  1. 毎週ログファイルの循環

  2. ログファイルは削除される前に5回循環します。

/etc/logrotate.d/httpdだからファイルに次の値を追加したい

weekly

rotate 5

これがファイルを回転させるのに必要なすべてであることをアドバイスしてください。現在の設定はログを循環しません。私のRed Hatシステムバージョン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
 }

ベストアンサー1

おすすめ記事