Limit log size for ufw 限制 log 文件大小
There is separate daemon called logrotated
that take care about rotating and deleting old logs. You should have config file for ufw in /etc/logrotate.d/ufw.
1 |
cat /etc/logrotate.d/ufw |
logrotate 是基于 cron 来运行的,其脚本是/etc/cron.daily/logrotate,实际运行时,Logrotate 会调用配置文件/etc/logrotate.conf。
然后我们看一下 ufw 的配置文件:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
/var/log/ufw.log { rotate 4 weekly missingok notifempty compress delaycompress sharedscripts postrotate invoke-rc.d rsyslog reload >/dev/null 2>&1 || true endscript } |
也就是默认自带有 logrotate 的功能,是 weekly 会 rotate 一次,4 表示只保留最近 4 周的 log。
参考文献: