Skip to content

Managing log files by using logrotate utility

Taymindis Woon edited this page Feb 26, 2018 · 2 revisions

For daily rotate, max rotated file is 31 count please follow the step below:-

sudo vim /etc/logrotate.d/nginx

/etc/nginx/logs/*.log {
        daily
        missingok
        rotate 31
        compress
        delaycompress
        notifempty
        create 640 myusername adm
        sharedscripts
        postrotate
                [ -f /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
        endscript
}

sudo logrotate /etc/logrotate.d/nginx

Clone this wiki locally