nginx windows 清理日志文件

今天在访问我的站点时发现一些 css , js 静态文件加载失败:net::ERR_CONTENT_LENGTH_MISMATCH 200 (OK)

经排查,有可能是 nginx 代理出现故障,遂去查看日志文件,发现 nignx/logs 下的 access.log 文件达800m。直接打开是不行了,看看能否清空日志,重新访问一下站点,再看最新的日志。

1. 我尝试删除日志,右键日志文件,删除:没有权限操作

2. 访问 http://nginx.org/en/docs/windows.html 看看有没有日志操作方面的命令,果然有:

ginx/Windows runs as a standard console application (not a service), and it can be managed using the following commands:

nginx -s stop	fast shutdown
nginx -s quit	graceful shutdown
nginx -s reload	changing configuration, starting new worker processes with a new configuration, graceful shutdown of old worker processes
nginx -s reopen	re-opening log files

于是我用 nginx -s reopen 来重新打开日志文件,仍提醒没有权限

按本人经验,我先把 nginx 服务关闭,nginx -s quit 再 nginx -s reopen 再启动 nginx 日志文件大小果然清空了。

接下来,我就可以继续排查问题了。

原文地址:https://www.cnblogs.com/chenrh/p/12829674.html