轮转策略有两种:
一、使用logrotate
配置好相关文件的轮转配置文件,系统会自动轮转
# rm -rf /etc/logrotate.d/httpd //删除httpd日志轮转配置文件
# rm -rf /var/log/httpd/access_log-* //删除历史轮转文件
# vim /etc/logrotate.d/httpd //编写自己的httpd日志轮转文件
/var/log/httpd/access_log { daily dateext rotate 10 create 0664 root apache postrotate /bin/systemctl restart httpd || true endscript }
# logrotate -vf /etc/logrotate.d/httpd //手动进行轮转
# 开启两个终端,实时打印,查看httpd日志文件和旧的日志文件。(tail -0f)