-[[Apacheのログ・ローテーション設定(access_log、error_logのlogrotate) [Fedora, RedHat]:http://memorva.jp/memo/linux/apache_logrotate.php]] #author("2023-04-04T04:21:59+00:00","default:admin","admin") * logrotate によるローテーション [#sc0b53e6] -[[logrotate によるログのローテーション:http://linux.kororo.jp/cont/server/logrotate.php]] -[[logrotateの不思議!:http://kansai.anesth.or.jp/gijutu/unix/man-postfix/www.kozupon.com/logrotate/logrotate.html]] -/etc/logrotate.d/httpd の例 (1) /usr/local/apache2/logs/*log { daily missingok ifempty sharedscripts postrotate /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true EXT=`date +%Y%m%d` for i in $1; do /bin/mv $i.1 $i.$EXT /bin/gzip $i.$EXT /bin/mv /usr/local/apache2/logs/*gz /usr/local/apache2/logs/old/. done EXT=`date +%Y%m%d --date '14 days ago'` /bin/rm -rf /usr/local/apache2/logs/old/*.${EXT}.gz >/dev/null 2>&1 endscript } -/etc/logrotate.d/httpd の例 (2) /etc/httpd/logs/*log { daily missingok ifempty sharedscripts postrotate /usr/local/apache2/bin/apachectl graceful 2> /dev/null endscript lastaction EXT=`date +%Y%m%d` for i in $1; do /bin/mv $i.1 $i.$EXT /bin/gzip $i.$EXT /bin/mv /etc/httpd/logs/*gz /etc/httpd/logs/old/. done EXT=`date +%Y%m%d --date '14 days ago'` /bin/rm -rf /etc/httpd/logs/old/*.${EXT}.gz >/dev/null 2>&1 endscript } * ログ・ローテーションのための再起動 [#h5d2aa27] -[[停止と再起動:http://httpd.apache.org/docs/2.0/ja/stopping.html]] -graceful で再起動をオススメ