nginx---进程开启、关闭和重载配置文件
来源:互联网 发布:淘宝饰品创业计划书 编辑:程序博客网 时间:2024/06/07 12:40
环境:
centOS6.4 32位
原文地址:http://nginx.org/en/docs/control.html
TERM, INTfast shutdownQUITgraceful shutdown 当请求处理完毕后才关闭进程HUPchanging configuration, keeping up with a changed time zone (only for FreeBSD and Linux), starting new worker processes with a new configuration, graceful shutdown of old worker processesUSR1re-opening log files USR2upgrading an executable fileWINCHgraceful shutdown of worker processes启动进程
# /usr/local/nginx/sbin/nginx
[root@localhost ~]# /usr/local/nginx/sbin/nginx
[root@localhost ~]# ps aux | grep nginx
root 6015 0.0 0.1 3472 516 ? Ss 14:34 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody 6016 0.0 0.1 3656 864 ? S 14:34 0:00 nginx: worker process
root 6018 0.0 0.1 4356 732 pts/0 S+ 14:34 0:00 grep nginx
关闭进程
[root@localhost ~]# ps aux | grep nginx
root 6015 0.0 0.1 3472 516 ? Ss 14:34 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody 6016 0.0 0.1 3656 864 ? S 14:34 0:00 nginx: worker process
root 6018 0.0 0.1 4356 732 pts/0 S+ 14:34 0:00 grep nginx
[root@localhost ~]# kill -QUIT 6015
[root@localhost ~]# ps aux | grep nginx
root 6020 0.0 0.1 4356 732 pts/0 S+ 14:37 0:00 grep nginx
在不关闭进程的情况下,重载配置文件
[root@localhost logs]# kill -HUP 6022
# cd /usr/local/nginx/logs
# ll
-rw-r--r--. 1 root root 2619 Sep 22 13:46 access.log
-rw-r--r--. 1 root root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 13:34 nginx.pid
# mv access.log access-111.log
# ll
-rw-r--r--. 1 root root 2619 Sep 22 13:46 access-111.log
-rw-r--r--. 1 root root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 13:34 nginx.pid
重新访问页面后
# ll
-rw-r--r--. 1 root root 4479 Sep 22 14:23 access-111.log
-rw-r--r--. 1 root root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 13:34 nginx.pid
访问日志名改变了,但还是继续写入了
重新启动服务或者重载配置文件以及使用USR1 都会新建日志文件
[root@localhost logs]# rm -rf access-111.log
[root@localhost logs]# ll
total 8
-rw-r--r--. 1 root root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 14:39 nginx.pid
[root@localhost logs]# kill -quit 6022
[root@localhost logs]# ps aux | grep nginx
root 6038 0.0 0.1 4356 732 pts/0 S+ 14:44 0:00 grep nginx
[root@localhost nginx]# ./sbin/nginx
[root@localhost nginx]# ps aux | grep nginx
root 6041 0.0 0.1 3472 516 ? Ss 14:44 0:00 nginx: master process ./sbin/nginx
nobody 6042 0.0 0.1 3656 864 ? S 14:44 0:00 nginx: worker process
root 6044 0.0 0.1 4356 732 pts/0 S+ 14:44 0:00 grep nginx
[root@localhost nginx]# ll logs/
total 8
-rw-r--r--. 1 root root 0 Sep 22 14:44 access.log
-rw-r--r--. 1 root root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 14:44 nginx.pid
[root@localhost nginx]# rm -rf logs/access.log
[root@localhost nginx]# ll logs/
total 8
-rw-r--r--. 1 root root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 14:44 nginx.pid
[root@localhost nginx]# ps aux | grep nginx
root 6041 0.0 0.1 3472 516 ? Ss 14:44 0:00 nginx: master process ./sbin/nginx
nobody 6042 0.0 0.1 3656 864 ? S 14:44 0:00 nginx: worker process
root 6050 0.0 0.1 4356 728 pts/0 S+ 14:49 0:00 grep nginx
[root@localhost nginx]#
[root@localhost nginx]# kill -HUP 6041
[root@localhost nginx]# ll logs/
total 8
-rw-r--r--. 1 root root 0 Sep 22 14:50 access.log
-rw-r--r--. 1 root root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 14:44 nginx.pid
[root@localhost nginx]# rm -rf logs/access.log
[root@localhost nginx]# ll logs/
total 8
-rw-r--r--. 1 root root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 14:44 nginx.pid
[root@localhost nginx]# kill -USR1 6041
[root@localhost nginx]# ll logs/
total 8
-rw-r--r--. 1 nobody root 0 Sep 22 14:51 access.log
-rw-r--r--. 1 nobody root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 14:44 nginx.pid
- nginx---进程开启、关闭和重载配置文件
- windows下开启关闭nginx
- Linux-Nginx-关闭进程
- windows--nginx关闭进程
- Qt 开启进程,查找进程,关闭进程
- 进程关闭与开启代码
- lnmp开启nginx和php-cgi多个进程
- 关闭和开启自动更新
- SVN开启和关闭
- 定时器开启和关闭
- SELinux 开启和关闭
- jenkins开启和关闭
- Nginx开启关闭文件目录显示方法
- vb 已经关闭进程的自动开启
- MFC开启与关闭外部进程
- CentOS 端口开启和关闭 防火墙的开启和关闭
- linux 关闭防火墙和开启
- 数据库的开启和关闭
- ServletConfig和ServletContext 总结
- JavaScript表单验证示例
- SpringBatch的领域概念
- 深入理解计算机系统-第1章计算机系统漫游
- U盘安装 centos7 dev root does exist
- nginx---进程开启、关闭和重载配置文件
- 百钱买百鸡问题
- android开发步步为营之29:选项菜单OptionsMenu的用法
- 冒泡排序 java
- [笔试]阿里笔试-最长公共连续子序列
- 命令模式
- 线性表之单链表学习小结(初学数据结构必看)
- hdu 2242(边双联通分量)
- javase和javaee中获取文件路径的方法总结