Find Node JS instance on Ubuntu

javascript, node.js, terminal, ubuntu

Solution

Example of output from `ps -aux | grep node`:

foo      22210  0.0  0.5 779600 46088 pts/2    Sl   Jan22   2:29 node ./server.js localhost:9999
foo      22794  0.0  0.0 692468   112 pts/4    Sl   Jan31   0:00 node ./static.js

These show two servers I've started. The process id is in the 2nd column so if I want to end the server that is running `server.js`, then:

kill 22210

If that does not work:

kill -9 22210

Generally speaking, I prefer to start with the kill without a signal option, which sends a `TERM` signal. If that does not work, then `-9`, which sends `KILL`. In the general case, `TERM` will give a chance to the process to terminate cleanly.

Problem

I wrote a script without putting `process.exit(0)` after I looked out for the ctrl c, `process.on('SIGNIT', gracefulShutdown)` I want to know if the process is still running on my machine, I used: `ps -aux | grep node` It came up with something but i'm not sure what it is. All I want to do is find a quick easy way of finding the process and kill it. Thanks

Original source