分类:Linux日志 发布时间:2017-09-20 11:02:18 阅读: 作者:郑祥景
nano /etc/logrotate.d/nginx
加入配置:
/var/log/nginx/*.log { daily missingok rotate 14 compress delaycompress notifempty create 0640 www www sharedscripts prerotate if [ -d /etc/logrotate.d/httpd-prerotate ]; then \ run-parts /etc/logrotate.d/httpd-prerotate; \ fi \ endscript postrotate invoke-rc.d nginx rotate >/dev/null 2>&1 endscript }
注意:create项后的用户,权限要设置和nginx运行权限一致,以防出现问题
运行:
logrotate -vf /etc/logrotate.d/nginx
参考:http://www.osyunwei.com/archives/9787.html
编辑:郑祥景