I was asked about killing a process in an interview and my answer was close, but not quite correct. I realized it wasn’t correct when I found myself actually having to do it just days later. Let’s say you have a node app running that you want to kill.
ps aux | grep "node"
ps aux will list all processes. We pipe it into grep to find our node process.
The kill command kills the process. pid is a placeholder for the actual process id that we get from
This has been a quick-n-dirty guide to finding and killing a process.
UPDATE: I found an even easier way to kill processes. The
pidof command will find the pid of a process. You may have to
brew install pidof or
apt-get install pidof if you don’t have it, but once you do then running the following command will show you the pid of your node app.
This may give you multiple pid’s if multiple node apps are running. You can kill them all with one simple command.
kill $(pidof node)
UPDATE: Yet another very easy way to kill a process
$ pgrep node
$ kill 93498