いろいろ試行錯誤

調べものしたときの覚書きや、仕事でコーディングした時のメモ などなど…

Apacheのアクセスログの保存期間を変更

/etc/logrotate.conf の初期状態

# view /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

# 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 -- we'll rotate them here
/var/log/wtmp {
    monthly
    minsize 1M
    create 0664 root utmp
    rotate 1
}

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

Apacheログローテーションの設定ファイル

# view /etc/logrotate.d/httpd

/var/log/httpd/*log {
    rotate 53   #←[追加]53週(約1年)分
    compress    #←[追加]圧縮保存
    missingok
    notifempty
    sharedscripts
    postrotate
        /sbin/service httpd reload > /dev/null 2>/dev/null || true
    endscript
}