Linux process automatically starts again with new new PID after killing - node.js

I wanna stop Node server on linux but when I try to stop it, It automatically starts with new PID how can I stop this completely. Here you can see I tried to stop Nginx and Node.
How can I check if it is a linux zombie process? If yes then How can I kill it? otherwise
I have tried tried these commands.
kill pid
Kill -9 pid
killall node <<command not working

This was spawn by it's parent process, I search out parent process after killing that this stop as well.

Related

How to make killall close the terminal that the process is in?

So how can I close the terminal where the process is in with killall.
I have tried this:
In 1st terminal:
killall node
In 2nd terminal:
Ready
Terminated
But I want only the 2nd terminal to close after the node is killed.
You can use the -t option:
killall -t $(tty)
will call all processes started from the terminal session (even with nohup), including the shell. So, your terminal will get closed.
You need to also kill the process which runs the terminal, which is usually the parent process of the node process.
The question How do I get the parent process ID of a given child process? is a good place to start. You can find the PIDs of the node processes via How to find the Process ID of a running terminal program.

Node child process doesn't release port, even after it's killed by parent

I have a parent node process and a child node process. The child binds a web server to port 5000. The parent sometimes kills and restarts the child (usually because a file has changed).
The problem is: when the second child process starts, I get Error: listen EADDRINUSE :::5000.
The weird thing is, I kill the child process with child.kill(), then I wait for it to fire a close event, and then I wait 5 seconds with setTimeout, before trying to start a new child process...yet it always complains that the port is occupied. But if I manually kill the parent process (ctrl+C in my terminal) and run it again, I don't get the error. So killing the parent seems to be the only way to successfully release the port.
Can anyone think of a reason why this would happen? Why does the port remain occupied after the process that bound it is killed, until its parent process stops?
Actually it block the process so you need to kill the process by following command just type
ps -ax
You will get list of processes from where you need to check the process id which is been blocked then kill the process by this command
kill -9 processId
Kill all your running port by below command.
pkill node

Linux killing process with kill -9 PID

Tried with some examples like ps and ps -ef,after killing a process by using kill-9 PID in Linux,how to verify weather the process is killed or not?
Just run ps aux stat,pid again, and you will see the process with this pid is either a zombie ('Z' in the first column) or dead.
Edit:
Thanks, Mark B, for pointing me about zombies.
Ater the kill, check the PID of the process:
$ pidof PROCESS
You should see no output if the process is gone.
Another similar way:
$ ps aux | grep PROCESS
Notes:
You can kill your own process, but only root user can kill system process or another user process.
After you KILL the process you can get a zombie, you can still see it in the process list but with process STATE Z (wich means Zombie). Zombies cant be killed, they are already dead, so to "kill" zombies you need to kill the zombie's parents. That said, in general you don’t need to get rid of zombie processes unless you have a large amount of them.

Shell Script for Killing PID

I run a few processes that I created myself on my Ubuntu Server, and to kill them I run:
sudo fuser -n tcp PORT
kill -9 PID-DISPLAYED
Is there any way I can obtain the PID from a port using a shell script, then kill it by running the shell script.
Thanks.
fuser can kill it:
-k, --kill
Kill processes accessing the file. Unless changed
with -SIGNAL, SIGKILL is sent. An fuser process
never kills itself, but may kill other fuser processes.
The effective user ID of the process executing fuser is
set to its real user ID before attempting to kill.
Try using either killall, or pkill, either of which will close all processes of the type of argument you describe, for example:
killall firefox
Will kill all running instances of firefox.
See
this link of pkill.

how to kill process in linux which was not killed

Hi I am developing a application in linux for which I am writing a shell script to run ffmpeg and it was working fine but when i want to kill the process of ffmpeg it was not working
kill 2628
where 2628 is my process id
you can use pkill command to force kill the process it will definitely kill the process just try it

Resources