天天看點

nginx: [alert] kill(2480, 10) failed (3: No such process)的解決辦法及nginx服務常用指令總結

【問題描述】

更改完nginx.conf檔案後,執行/app/nginx/sbin/nginx -s reload指令重新加載配置檔案,報以下錯誤資訊:

1

<code>nginx: [alert] kill(2480, 10) failed (3: No such process)</code>

   提示沒有相關程序。

【解決】

其實這個問題很低級的說,就是我之前壓根就沒有啟動nginx服務,執行/app/nginx/sbin/nginx,開啟nginx服務後,重新加載nginx配置,一切正常!

【附錄】

nginx幫助資訊

2

3

4

5

6

7

8

9

10

11

12

13

14

<code># /app/nginx/sbin/nginx -h</code>

<code>nginx version: nginx/1.6.3</code>

<code>Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]</code>

<code>Options:</code>

<code>  </code><code>-?,-h         : this help</code>

<code>  </code><code>-v            : show version and exit</code>

<code>  </code><code>-V            : show version and configure options then exit</code>

<code>  </code><code>-t            : test configuration and exit</code>

<code>  </code><code>-q            : suppress non-error messages during configuration testing</code>

<code>  </code><code>-s signal     : send signal to a master process: stop, quit, reopen, reload</code>

<code>  </code><code>-p prefix     : set prefix path (default: /app/nginx-1.6.3/)</code>

<code>  </code><code>-c filename   : set configuration file (default: conf/nginx.conf)</code>

<code>  </code><code>-g directives : set global directives out of configuration file</code>

nginx服務管理常用指令

<code>/app/nginx/sbin/nginx -h 檢視nginx幫助資訊</code>

<code>nginx -s stop,     — fast shutdown</code>

<code>nginx -s quit,     — graceful shutdown 字面意思為優雅的關閉,個人了解應該是安全的關閉吧</code>

<code>nginx -s reopen    — reopening the log files 重新打開日志檔案</code>

<code>nginx -s reload    — reloading the configuration file  重新加載配置檔案</code>

<code># /app/nginx/sbin/nginx -t  檢查配置</code>

<code>nginx: the configuration file /app/nginx-1.6.3/conf/nginx.conf syntax is ok</code>

<code>nginx: configuration file /app/nginx-1.6.3/conf/nginx.conf test is successful</code>

關閉nginx服務

# /app/nginx/sbin/nginx -s stop

# pkill -9 nginx 強制關閉

ps -ef |head -1;ps -ef |grep nginx

UID        PID  PPID  C STIME TTY          TIME CMD

root      2114     1  0 00:39 ?        00:00:00 nginx: master process /app/nginx/sbin/nginx

nginx     2115  2114  0 00:39 ?        00:00:00 nginx: worker process

root      2126  1660  0 00:41 pts/0    00:00:00 grep nginx

 # kill 2114

 # pgrep nginx

 # /app/nginx/sbin/nginx

 # pgrep nginx          

    2150

    2151

ps -A | grep nginx | grep -v grep | awk '{ print $1; }' |head -1 |xargs -L 1 kill -QUIT

使用xargs -L 1確定每次隻取一行内容,然後使用kill -QUIT關閉nginx

啟動nginx服務

/app/nginx/sbin/nginx

# ps -ef |head -1;ps -ef |grep nginx                

root      2157     1  0 00:47 ?        00:00:00 nginx: master process /app/nginx/sbin/nginx

nginx     2158  2157  0 00:47 ?        00:00:00 nginx: worker process

root      2174  1660  0 00:52 pts/0    00:00:00 grep nginx

# kill -HUP 2157

# pgrep nginx

2157

2175

對配置檔案更改後,可使用kill -HUP指令在不停止原有服務的情況下重新加載配置,有點nginx -s reload的味道。

本文轉自 xoyabc 51CTO部落格,原文連結:http://blog.51cto.com/xoyabc/1702696,如需轉載請自行聯系原作者

繼續閱讀