Welcome! Log In Create A New Profile

Advanced

[nginx]access log and error log

Posted by 桐山 健太郎 
桐山 健太郎
[nginx]access log and error log
August 28, 2018 03:00AM
Hello,

I’m suffering a problem with access.log and error.log for nginx.service on RHEL 7.4.

The problem is either access.log and error.log are not recording the log.

To solve this issue, I have tried multiple time changing logrotation setting for nginx.

Below is the setting of logrotation for nginx.service.(/etc/logrotate.d/nginx)

/var/log/nginx/*.log {
daily
missingok
rotate 7
compress
create 644 nginx adm
sharedscripts
postrotate
if [ -f /var/run/nginx.pid ]; then
kill -USR1 'cat /var/run/nginx.pid'
fi
endscript
}

By the way, the log will start recording on both log files after restarting the nginx.service.

I would like to know the issue on here and how to solve it.

Regards,
Kentaro

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Josh Cooley
Re: [nginx]access log and error log
August 28, 2018 07:10AM
Your postrotate script contains single ticks (') instead of backticks (`),
but you should really use the $( command ) construct if your /bin/sh is
bash.

INCORRECT (what you have now):

if [ -f /var/run/nginx.pid ]; then

kill -USR1 'cat /var/run/nginx.pid'

fi

CORRECT, BUT ARCHAIC:

if [ -f /var/run/nginx.pid ]; then

kill -USR1 `cat /var/run/nginx.pid`

fi

CORRECT AND MODERN:

if [ -f /var/run/nginx.pid ]; then

kill -USR1 $(cat /var/run/nginx.pid)

fi


On Mon, Aug 27, 2018 at 7:49 PM, 桐山 健太郎 <[email protected]> wrote:

> Hello,
>
>
>
> I’m suffering a problem with access.log and error.log for nginx.service on
> RHEL 7.4.
>
>
>
> The problem is either access.log and error.log are not recording the log.
>
>
> To solve this issue, I have tried multiple time changing logrotation
> setting for nginx.
>
>
>
> Below is the setting of logrotation for nginx.service.(/etc/logrotate.
> d/nginx)
>
>
>
> /var/log/nginx/*.log {
>
> daily
>
> missingok
>
> rotate 7
>
> compress
>
> create 644 nginx adm
>
> sharedscripts
>
> postrotate
>
> if [ -f /var/run/nginx.pid ]; then
>
> kill -USR1 'cat /var/run/nginx.pid'
>
> fi
>
> endscript
>
> }
>
>
>
> By the way, the log will start recording on both log files after
> restarting the nginx.service.
>
>
>
> I would like to know the issue on here and how to solve it.
>
>
>
> Regards,
>
> Kentaro
>
>
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
桐山 健太郎
RE: [nginx]access log and error log
August 28, 2018 08:20AM
Hi, Josh

Appreciate for your advice.
I will try either both of those and will try to fix this issue.

Regards,
Kentaro

From: nginx [mailto:[email protected]] On Behalf Of Josh Cooley
Sent: Tuesday, August 28, 2018 2:02 PM
To: nginx@nginx.org
Cc: 小栗 雅士; 千葉 幸宏
Subject: Re: [nginx]access log and error log

Your postrotate script contains single ticks (') instead of backticks (`), but you should really use the $( command ) construct if your /bin/sh is bash.

INCORRECT (what you have now):
if [ -f /var/run/nginx.pid ]; then
kill -USR1 'cat /var/run/nginx.pid'
fi

CORRECT, BUT ARCHAIC:
if [ -f /var/run/nginx.pid ]; then
kill -USR1 `cat /var/run/nginx.pid`
fi

CORRECT AND MODERN:
if [ -f /var/run/nginx.pid ]; then
kill -USR1 $(cat /var/run/nginx.pid)
fi


On Mon, Aug 27, 2018 at 7:49 PM, 桐山 健太郎 <[email protected]<mailto:[email protected]>> wrote:
Hello,

I’m suffering a problem with access.log and error.log for nginx.service on RHEL 7.4.

The problem is either access.log and error.log are not recording the log.

To solve this issue, I have tried multiple time changing logrotation setting for nginx.

Below is the setting of logrotation for nginx.service.(/etc/logrotate.d/nginx)

/var/log/nginx/*.log {
daily
missingok
rotate 7
compress
create 644 nginx adm
sharedscripts
postrotate
if [ -f /var/run/nginx.pid ]; then
kill -USR1 'cat /var/run/nginx.pid'
fi
endscript
}

By the way, the log will start recording on both log files after restarting the nginx.service.

I would like to know the issue on here and how to solve it.

Regards,
Kentaro


_______________________________________________
nginx mailing list
[email protected]<mailto:[email protected]>
http://mailman.nginx.org/mailman/listinfo/nginx

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login