linux – Logrotate不会删除旧日志
发布时间:2020-12-13 17:57:50 所属栏目:Linux 来源:网络整理
导读:由于某种原因,旧的日志文件不会被删除.用apache的例子 conf文件说的是什么: $cat /etc/logrotate.d/apache2/var/log/apache2/*.log { weekly missingok rotate 2 compress delaycompress notifempty create 640 root adm sharedscripts postrotate /etc/ini
由于某种原因,旧的日志文件不会被删除.用apache的例子
conf文件说的是什么: $cat /etc/logrotate.d/apache2 /var/log/apache2/*.log { weekly missingok rotate 2 compress delaycompress notifempty create 640 root adm sharedscripts postrotate /etc/init.d/apache2 reload > /dev/null endscript } 日志文件夹的(裁剪)内容: # ls /var/log/apache2/ access.log error.log.26.gz other_vhosts_access.log.20.gz access-ssl.log.14.gz access.log.1 error.log.27.gz other_vhosts_access.log.21.gz access-ssl.log.15.gz access.log.2.gz error.log.28.gz other_vhosts_access.log.22.gz access-ssl.log.16.gz access.log.3.gz error.log.2.gz other_vhosts_access.log.23.gz access-ssl.log.17.gz [...] 实际上有很多: # ls /var/log/apache2/ | wc -l 85 使用–verbose的logrotate命令给了我: # /usr/sbin/logrotate --verbose /etc/logrotate.conf [...] reading config file apache2 reading config info for /var/log/apache2/*.log [...] rotating pattern: /var/log/apache2/*.log weekly (2 rotations) empty log files are not rotated,old logs are removed considering log /var/log/apache2/access.log log does not need rotating considering log /var/log/apache2/error.log log does not need rotating considering log /var/log/apache2/other_vhosts_access.log log does not need rotating considering log /var/log/apache2/pbpdhg-ssl.log log does not need rotating not running postrotate script,since no logs were rotated [...] 这有什么不对? 解决方法
你的配置说:旋转2
这意味着日志文件在被删除之前会被旋转2次,因此logrotate只关注2个文件. 我的猜测是配置在某些时候发生了变化,因为以前保存了更多的日志文件,也许就像旋转28.这些旧文件你必须手动删除. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |