Solved the problem that the log is no longer recorded after the Nginx log is compressed

nginx is installed for yum, and it is found that the log cannot be recorded normally after being compressed. It turns out that when nginx is installed by default, the nginx configuration vim /ect/logrotate.d/nginx
will be added under /ect/logrotate.d/

   /data/logs/nginx/*log {
    daily
    rotate 10
    missingok
    notifempty
    compress
    sharedscripts
    postrotate
        /etc/init.d/nginx reopen_logs
    endscript
}


Execute /etc/init.d/nginx reopen_logs and find that the execution fails.
Replace that command with
[ ! -f /usr/local/nginx/logs/nginx.pid ] || kill -USR1 `cat /usr/local/nginx/logs/nginx.pid`

where /usr/local/nginx/ logs/nginx.pid is the storage address of the pid configured in nginx.conf.
The problem is solved.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326613518&siteId=291194637