跳至正文
Wener Notes

logrotate

约 1 分钟阅读
  • /etc/logrotate.conf
  • /etc/logrotate.d/
  • 通过 cron 执行
bash
# 配置 /etc/logrotate.conf
# 任务 /etc/periodic/daily/logrotate
apk add logrotate
logrotate.conf
include /etc/logrotate.d

配置

ini
/var/log/apache2/* {
    weekly
    rotate 3
    size 10M
    compress
    delaycompress
}

/var/log/squid/access.log {
    monthly
    create 0644 root root
    rotate 5
    size=1M
    dateext
    dateformat -%d%m%Y
    notifempty
    # mail [email protected]
}

/var/log/k3s.log {
        missingok
        notifempty
        sharedscripts
        postrotate
                /etc/init.d/k3s --quiet --ifstarted restart || true
        endscript
}
bash
# -d debug - 不会执行
logrotate -d /etc/logrotate.d/apache2.conf
# -v verbose - 会执行
logrotate -v /etc/logrotate.d/apache2.conf

关联信息

反向链接、本文链接的其他页面和外部资料。

参考资料

GitHub1 条
其他外链1 条
最近更新commit 064f6da编辑