How to httpd-access.log
rotation
【Last modified
】
【はじめに】
Apache は、HUP signal を受け取ると、新しいlogを書き始める。
/etc/syslog.conf は、第8フィールドにプロセス番号を指定して SIGHUP
を送るように設定できる。
man newsyslog
path_to_pid_file
This optional field specifies the file name to read to find
the daemon process id. If this field is present, a SIGHUP is sent the process
id contained in this file. This field must start with "/" in order to be
recognized properly.
【某FreeBSD 2.2.8-Sマシンの/etc/newsyslog.confより】
# configuration file for newsyslog
# $Id: newsyslog.conf,v 1.6.2.4 1998/04/14 23:08:29 jmb Exp $
#
# logfilename owner.group mode count size time [ZB] [/pid_file]
/var/cron/log 600 3 100 * Z
/var/log/amd.log 664 7 100 * Z
/var/log/kerberos.log 664 7 100 * Z
/var/log/lpd-errs 664 7 100 * Z
/var/log/maillog 664 7 * 24 Z
/var/log/sendmail.st 664 10 * 168 B
/var/log/messages 664 5 100 * Z
/var/log/slip.log 600 3 100 * Z
/var/log/ppp.log 600 3 100 * Z
/var/log/httpd-access.log 644 7 * 1 Z /var/run/httpd.pid
の様に書いておくと
【ログファイル】
/var/log/httpd-access.log
-rw-r--r-- 1 root bin 75255 May 7 11:00 httpd-access.log.1.gz
-rw-r--r-- 1 root bin 24823 May 7 12:00 httpd-error.log
という具合になる。ログのローテーション間隔の設定は御好みでどうぞ!
などと、書いておりましたが、更に時代は流れ.........newsyslog も進化なさったようで、(^^;
# configuration file for newsyslog
# $FreeBSD: src/etc/newsyslog.conf,v 1.25.2.4 2001/02/26 09:26:11 phk Exp $
#
# logfilename [owner:group] mode count size when [ZB] [/pid_file] [sig_num]
/var/log/cron 600 3 100 * Z
/var/log/wtmp 644 3 * @01T05 B
/var/log/httpd-access_log 644 12 * @01T05 Z /var/run/httpd.pid
の様に、time から when に変わったフィールドに @01T05 と書いておくと、毎月1日の午前5時にログファイルをローテートし、アパッチに HUP Signal を送ってくれます。