Reputation: 8165
access.log
is created as the root
user. When this fills up, nginx
rotates it and creates a new one.
-rw-r----- 1 nginx adm 306753808 Mar 15 15:47 access.log
-rw-r--r-- 1 root root 1197875535 Mar 15 06:25 access.log.1
However the new one is created with the nginx
user as privileged. This becomes a problem when an agent needs to read off this log file.
How do I set this so that when it rotates log it creates it with root
or atleast have a different symbolic value
Upvotes: 1
Views: 1859
Reputation: 1980
Check your /etc/logrotate.d/nginx if you have a line to set the right user and group permissions like this (line 2):
# cat -n /etc/logrotate.d/nginx
1 /var/log/nginx/*log {
2 create 0644 nginx adm
3 daily
4 rotate 10
5 missingok
6 notifempty
7 compress
8 sharedscripts
9 postrotate
10 /bin/kill -USR1 `cat /run/nginx.pid 2>/dev/null` 2>/dev/null || true
11 endscript
12 }
Upvotes: 2