How to kill this immortal nginx worker?
Asked Answered
I

3

20

I have started nginx and when I stop like root

/etc/init.d/nginx stop

after that I type

ps aux | grep nginx

and get response like tcp LISTEN 2124 nginx WORKER

kill -9 2124  # tried with kill -QUIT 2124, kill -KILL 2124

and after I type again

ps aux | grep nginx

and get response like tcp LISTEN 2125 nginx WORKER and so on.

How to kill this immortal Chuck Norris worker ?

Impressionist answered 2/9, 2013 at 15:44 Comment(3)
I know this is silly, but did you try sudo service nginx stop ?Overrate
In my case i had no nginx installed, gitlab was responsible to spawn the workers.Gailey
Have you tried disable from systemd? systemctl disable nginx.service and try to kill -9 PID. Thats work for meKnott
P
6

After kill -9 there's nothing more to do to the process - it's dead (or doomed to die). The reason it sticks around is because either (a) it's parent process hasn't waited for it yet, so the kernel holds the process table entry to keep it's status until the parent does so, or (b) the process is stuck on a system call into the kernel that is not finishing (which usually means a buggy driver and/or hardware).

If the first case, getting the parent to wait for the child, or terminating the parent, should work. Most programs don't have a clear way to make them "wait for a child", so that may not be an option.

In the second case, the most likely solution is to reboot. There may be tools that could clear such a condition, but that's not common. Depending on just what that kernel processing is doing, it may be possible to get it to unblock by other means - but that requires knowledge of that processing. For example, if the process is blocked on a kernel lock that some other process is somehow holding indefinitely, terminating that other process could aleviate the problem.

Note that the ps command can distinguish these two states as well. These show up in the 'Z' state. See the ps man page for more info: http://linux.die.net/man/1/ps. They may also show up with the text "defunct".

Pestilent answered 2/9, 2013 at 21:45 Comment(0)
G
4

I had the same issue. In my case gitlab was the responsible to bring the nginx workers. when i completelly removed gitlab from my server i got able to kill the nginx workers.

  1. ps -aux | grep "nginx"

  2. Search for the workers and check at the first column who is bringing them up.

  3. kill or unistall the responsible and kill the workers again, they will stop spawning ;D

Gailey answered 6/3, 2018 at 14:41 Comment(0)
T
0

I was having similar issue.

Check if you are using any auto-healer like Monit or Supervisor which runs the worker whenever you try to stop them. If Yes Disable them.

My workers were being spawned due to changes I forget i made in update-rc.d in Ubuntu.

So I installed sysv-rc-conf which gives a clean interface control of what processes are on reboot, you can disable from there and I assure you no Chuck Noris Resurrection :D

Tantalous answered 13/4, 2016 at 13:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.