跳到主要内容

logrotate

# 配置 /etc/logrotate.conf
# 任务 /etc/periodic/daily/logrotate
apk add logrotate
logrotate.conf
include /etc/logrotate.d

配置

/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 gabriel@mydomain.com
}

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