ログローテーション
[root@localhost ~]# cat /etc/logrotate.conf
# see “man logrotate” for details
# rotate log files weekly
# 毎週ログのローテーションを行う
weekly
# keep 4 weeks worth of backlogs
# バックログを4週間のこす
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
# ローテーション周期を1ヶ月とする。権限とログの数
/var/log/wtmp {
monthly
create 0664 root utmp
rotate 1
}
# system-specific logs may be also be configured here.
[root@localhost ~]#
[root@localhost ~]# ls -l /var/log/secure*
-rw——- 1 root root 5078 11月 24 22:40 /var/log/secure
-rw——- 1 root root 1335 11月 17 23:31 /var/log/secure.1
-rw——- 1 root root 2195 11月 16 00:19 /var/log/secure.2
-rw——- 1 root root 4357 11月 4 23:18 /var/log/secure.3
-rw——- 1 root root 918 11月 3 00:49 /var/log/secure.4
[root@localhost ~]#
[root@localhost ~]# ls -l /var/log/wtmp
wtmp wtmp.1
※ logrotateの設定は、/etc/logrotate.confと/etc/logrotate.dディレクトリにある各設定ファイルで行います。
※ 各ログファイルの設定は、/etc/logrotated.dディレクトリの設定ファイルで行います。syslogdで設定されたログの設定ファイルは、/etc/logrotated.d/syslog
[root@localhost ~]# cat /etc/logrotate.d/syslog
/var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron {
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
endscript
}
[root@localhost ~]#