3

I'm using below cfg for log rotation by size but it's not working.

/var/log/nginx/access_log { rotate 7 size 5k dateext dateformat -%Y-%m-%d missingok compress sharedscripts postrotate test -r /var/run/nginx.pid && kill -USR1 `cat /var/run/nginx.pid` endscript } 

UPDATE 1:

user nginx; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" "$request_body"' ' "$http_UID" $status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; server { listen 80; server_name xyz; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } location /xyz/ { access_log /var/log/nginx/access.log main; proxy_pass http://localhost:13004/xyz/; } 
4
  • I've referred this - serverfault.com/a/427148/422461 Commented Jun 29, 2017 at 13:23
  • Did you check in /etc/nginx/nginx.conf that is really where your pid file lives? Which OS? Commented Jun 29, 2017 at 14:57
  • I've added my nginx conf and I'm using centos 7 Commented Jun 30, 2017 at 6:38
  • There is some strangeness in nginx log rotation. I am affected by the reported bug logrotate action "rotate" failed, not sure if it impacts your above configuration. Commented Jul 2, 2017 at 21:53

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.