nginx 日志循环

ubuntu安装nginx,默认使用logrotate进行日志管理。
logrotate能解决nginx不能分割日志的缺陷,我们需要对其进行适当配置。

vim /etc/logrotate.d/nginx

修改循环周期为天,以及其它参数:

/var/log/nginx/*.log {
    daily
    missingok
    rotate 20
    minsize 2M
    compress
    delaycompress
    notifempty
    create 0640 www-data adm
    sharedscripts
    prerotate
        if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
            run-parts /etc/logrotate.d/httpd-prerotate; \
        fi; \
    endscript
    postrotate
        [ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid`
    endscript
}

标签: nginx

添加新评论