You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Nginx经Logrotate轮转后无法写入自定义域名日志文件的问题求助

Nginx经Logrotate轮转后无法写入自定义域名日志文件的问题求助

大家好,我遇到了一个棘手的问题想请教各位:

我搭建了一个Nginx反向代理,日志文件是按域名自定义存放的,路径为/var/log/nginx/domain/fqdn.(log|err)。大概自从切换到Ubuntu 23.10之后,这些日志文件就经常是空的。

排查后发现,问题出在logrotate日志轮转之后:每次轮转完成,Nginx就无法再往各个日志文件写入内容了,必须手动重载、重启Nginx,或者强制触发一次logrotate才能恢复日志写入功能。

我试过把logrotate配置里的invoke-rc.d nginx rotate >/dev/null 2>&1替换成invoke-rc.d nginx reload >/dev/null 2>&1,但依然没能解决问题。另外我注意到,每个日志文件最后有内容的时间段都在00:00到00:15之间,正好对应logrotate执行轮转的时间点。

目前所有日志文件的所有者都是www-data:adm,权限掩码为644,看起来是正常的。

附上我的logrotate配置:

root@rev-proxy:~# cat /etc/logrotate.d/nginx

/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

}

有没有大佬能帮忙分析下问题根源?谢谢啦!

备注:内容来源于stack exchange,提问作者guillaumearnx

火山引擎 最新活动