惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
Attack and Defense Labs
Attack and Defense Labs
V2EX - 技术
V2EX - 技术
O
OpenAI News
S
Secure Thoughts
H
Heimdal Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Schneier on Security
Schneier on Security
H
Hacker News: Front Page
S
Security Affairs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
The Register - Security
The Register - Security
GbyAI
GbyAI
Cloudbric
Cloudbric
MongoDB | Blog
MongoDB | Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
K
Kaspersky official blog
Forbes - Security
Forbes - Security
Y
Y Combinator Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Scott Helme
Scott Helme
Hacker News - Newest:
Hacker News - Newest: "LLM"
The Cloudflare Blog
Recorded Future
Recorded Future
人人都是产品经理
人人都是产品经理
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
Webroot Blog
Webroot Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LangChain Blog
T
Tor Project blog
Microsoft Azure Blog
Microsoft Azure Blog
博客园_首页
Hacker News: Ask HN
Hacker News: Ask HN
Blog — PlanetScale
Blog — PlanetScale
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog RSS Feed
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
I
Intezer
V
V2EX
T
Tailwind CSS Blog
SecWiki News
SecWiki News
NISL@THU
NISL@THU
C
Check Point Blog

博客园 - 林杰的博客

7z系列之一:7zip SDK中C++模块的编译 WORD2012 中使用“全屏阅读” Office2012中使用“冻结窗格”功能锁定标题栏 开发工具:Visual Studio 2005下方便宜用的代码行统计工具 为Visual Assist设置快捷键 Visual Studio 2010的Python支持工具 让Win7资源管理器显示图片内容预览 Python 单元测试带案例名称输出 Linux 系统安装配置NTP时间服务器 Editplus中.proto文件的高亮文件 c#美味: 微软图表控件MSChart安装部署 测试工具:用性能监视器查看程序的性能 C#美味:Linq入门 讲座 C++零食:使用Unicode版的预定义宏__FUNCTION__ C++零食:VC中使用ForceInclude来强制包含stdafx.h C++零食:重启后消失的注册表键值 C++零食:WTL中使用双缓冲避免闪烁 C++零食:wprintf 中使用%I64d格式化输出LONGLONG C++零食:HRESULT 与 Windows Error Codes 不是一回事
Linux 使用pid文件结束nginx
林杰的博客 · 2011-03-21 · via 博客园 - 林杰的博客

nginx的结束重启一般是通过下面命令来实现的:

其中26000是nginx的主进程号。

每次都需要通过ps命令来查询nginx的主进程号,非常麻烦。 在《实战nginx:取代Apache的高性能Web服务器》一书中提到了使用pid文件的方法,不巧的是给的命令漏了些东西,这里给出完整的指令。

什么是pid文件

pid文件就是一个纯文本文件,里面记录的是进程的pid号。

下面是一个pid文件的内容::

26032

nginx的默认pid文件

nginx使用了pid文件来记录master process的pid号,如果编译时没有指定,那它的路径就是:

 <prefix>/logs/nginx.pid

其中<prefix>是nginx的安装路径。

如果你想修改默认的pid文件路径,可以在编译时加入配置。参数如下::

 ./configure –-pid-path=/data/test/ngx.pid

指定后,默认的pid文件路径就更改为::

/data/test/ngx.pid

如果指定只是路径,没有pid的文件名,那么pid的文件名还是nginx.pid

通过配置文件修改pid

除了使用默认值和通过编译时修改外,还可以通过在nginx的配置文件中修改。如下:

pid  /data/test/nginx.pid;

这里修改的值只对使用该配置文件的nginx有效。

用PID文件停止Nginx

假设pid文件路径为/data/logs/nginx.pid

kill –QUIT `cat /data/logs/nginx.pid`

用pid文件重新加载配置文件

kill –HUP `cat /data/logs/nginx.pid`