M
M
Michael2020-03-02 15:50:54
Nginx
Michael, 2020-03-02 15:50:54

How to properly rotate nginx logs?

The task is as follows:
this is the basic version that comes with a web server for archiving logs.

spoiler
/var/log/nginx/*.log {
        daily
        missingok
        rotate 14
        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
                invoke-rc.d nginx rotate >/dev/null 2>&1
        endscript
}


But my sites and log directories are located in the following form
/var/www/sitename.ru/log/filename*.log

How to write in the above script so as not to drop the server?
PS sites in /var/www pieces 10

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Karasik, 2020-03-02
@happy-cat

Just add the line
/var/log/nginx/*.log
/var/www/*/log/*.log
{
to the config

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question