Questions in category: Nginx (Nginx)
软件 >> Nginx [2]

1. Windows 下查找 Nginx 的进程号(Pid)

Posted by haifeng on 2025-09-05 09:45:59 last update 2025-09-05 09:45:59 | Answers (0) | 收藏


Pid 指 Process id, 进程号. 使用 tasklist 命令可以列出当前所有任务的状态信息. 由于有很多任务, 故将其信息通过管道导给 findstr 命令, 显示含有字符子串 "nginx.exe" 的所有信息. 

C:\Users\haife>tasklist | findstr "nginx.exe"
nginx.exe                    20436 Console                    5      8,352 K
nginx.exe                    24088 Console                    5      8,952 K

2. 使用awk分析Nginx的日志文件.

Posted by haifeng on 2025-06-08 14:53:05 last update 2025-06-08 14:53:05 | Answers (0) | 收藏


Nginx 的日志文件有 access.log 和 error.log. 前者记录用户访问的具体行为, 后者记录Nginx服务器碰到的错误.

awk是Linux 下的一个强大的文本分析工具.

比如 access.log 的每一行第一列记录的是用户的IP地址, 现在需要将 access.log 中所有IP地址打印到文件 IP_list.txt, 则可以用下面的命令.

$ awk '{print $1}' access.log > ~/IP_list.txt