相关疑难解决方法(0)

Logrotate 不会删除旧日志

由于某种原因,旧的日志文件不会被删除。以 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
}
Run Code Online (Sandbox Code Playgroud)

日志文件夹的(裁剪)内容:

# 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
[...]
Run Code Online (Sandbox Code Playgroud)

其实有很多:

# ls /var/log/apache2/ | wc -l
85
Run Code Online (Sandbox Code Playgroud)

带有 --verbose 的 logrotate 命令给了我这个:

# /usr/sbin/logrotate --verbose  /etc/logrotate.conf
[...]
reading config file apache2
reading config info for /var/log/apache2/*.log
[...]
rotating pattern: …
Run Code Online (Sandbox Code Playgroud)

linux logrotate

14
推荐指数
1
解决办法
3万
查看次数

标签 统计

linux ×1

logrotate ×1