看来 apache 会保存/压缩 14 天的日志。我现在看到这些日志文件
# ls
access.log access.log.12.gz access.log.3.gz access.log.7.gz error.log.1 error.log.13.gz error.log.4.gz error.log.8.gz
access.log.1 access.log.13.gz access.log.4.gz access.log.8.gz error.log.10.gz error.log.14.gz error.log.5.gz error.log.9.gz
access.log.10.gz access.log.14.gz access.log.5.gz access.log.9.gz error.log.11.gz error.log.2.gz error.log.6.gz other_vhosts_access.log
access.log.11.gz access.log.2.gz access.log.6.gz error.log error.log.12.gz error.log.3.gz error.log.7.gz other_vhosts_access.log.1
有没有什么办法可以增加天数?
答案1
是的,有。该文件/etc/logrotate.d/apache2
包含:
/var/log/apache2/*.log {
daily
missingok
rotate 14
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
if /etc/init.d/apache2 status > /dev/null ; then \
/etc/init.d/apache2 reload > /dev/null; \
fi;
endscript
prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \/var/log/apache2/*.log {
daily
missingok
rotate 14
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
if /etc/init.d/apache2 status > /dev/null ; then \
/etc/init.d/apache2 reload > /dev/null; \
fi;
endscript
prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
run-parts /etc/logrotate.d/httpd-prerotate; \
fi; \
endscript
}
run-parts /etc/logrotate.d/httpd-prerotate; \
fi; \
endscript
}
因此,您可以简单地sudoedit /etc/logrotate.d/apache2
将 更改rotate 14
为rotate 999
,或任何您喜欢的内容。
读man logrotate
。