码迷,mamicode.com
首页 > 系统相关 > 详细

关闭nginx进程

时间:2015-06-24 00:49:24      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:kill   awk   grep   aux   ps   

当然就只是介绍一条命令了,就这么简单。


nginx默认创建一个工作进程

root      2713     1  0 07:56 ?        00:00:00 nginx: master process ../sbin/nginx
nobody    2714  2713  0 07:56 ?        00:00:00 nginx: worker process

修改worker_processes=10,来创建多个进程

#user  nobody;
worker_processes  10;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

fuhui@ubuntu:/usr/local/nginx$ ps -ef | grep ‘nginx‘ 
root      2713     1  0 07:56 ?        00:00:00 nginx: master process ../sbin/nginx
nobody    2747  2713  0 08:00 ?        00:00:00 nginx: worker process
nobody    2748  2713  0 08:00 ?        00:00:00 nginx: worker process
nobody    2749  2713  0 08:00 ?        00:00:00 nginx: worker process
nobody    2750  2713  0 08:00 ?        00:00:00 nginx: worker process
nobody    2751  2713  0 08:00 ?        00:00:00 nginx: worker process
nobody    2752  2713  0 08:00 ?        00:00:00 nginx: worker process
nobody    2753  2713  0 08:00 ?        00:00:00 nginx: worker process
nobody    2754  2713  0 08:00 ?        00:00:00 nginx: worker process
nobody    2755  2713  0 08:00 ?        00:00:00 nginx: worker process
nobody    2756  2713  0 08:00 ?        00:00:00 nginx: worker process
fuhui     2852  2332  0 08:29 pts/6    00:00:00 grep --color=auto nginx

错误的执行方式
fuhui@ubuntu:/usr/local/nginx$ sudo ps -ef | grep ‘nginx‘ | awk ‘{kill -9 $2}‘ 

正确的执行方式
fuhui@ubuntu:/usr/local/nginx$ sudo kill ` ps -ef | grep ‘nginx‘ | awk ‘{print  $2}‘ `

To kill all Nginx Processes

kill $(ps aux | grep ‘[n]ginx‘ | awk ‘{print $2}‘)

使用“跟$()效果是一样的

关闭nginx进程

标签:kill   awk   grep   aux   ps   

原文地址:http://blog.csdn.net/whynottrythis/article/details/46612243

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!