Practical dev majik and devops: Finding your node Linux process

If you’re new (or beyond 42 years) to dev jobs, it might happen that..

  • you made some simple top-of-your-head Node server code
  • you ran the server with a $ node blahblahblah.js
  • …and left it running.

All is fine at this point, right? Absolutely. No funny-cat face yet needed. Alas:

  • later on, you logged in to the server, but have no idea how to “locate” your server as a Linux process

What was my Node server’s folder, again?!

Photo by Ramiz Dedaković on Unsplash

Soooo…. you remember your cute proof-of-concept server, hazily whipped on top of express is listening to port 3000, that’s for sure.

..but you’ve got no fricking idea which process your node is

man in brown long sleeve shirt holding book in white wooden book shelf
Photo by cottonbro on

..and as said, yeah, it’s a couple of weeks since your last visit on this Linux box… and it’s kind of Friday afternoonish… and you kind of would like to get the momentum going.

Two friends: ps and history

ps ax | grep -i 'node'

And behold! Bingo!

Look at the result:

  • importance of naming your entry point (ie the file that normally is index.js)
  • you can drill down more now that you’ve found the important thing, the pid number (in the screenshot it’s 640). There’s a whole lotta things that can be done. Google around for ‘linux ps’, ‘linux vtop’, ‘using vtop’

What is the ‘history’?

Linux and Macs have the command ‘history’. It’s really useful memory aide sometimes. History lists your entire command history, ie. the commands that you’ve entered into the shell. When sometimes running complex and long commands to run servers, or in doing any other devopsey magic, history can be really useful.

Just try it in the shell:


[su_note]Again, in the philosophy of Linux and *nix systems: treat output from tools as a valuable data to be further processed with other tools. grep is your powerhouse for finding snippets of text when you can describe the approximate (or precise) format. ‘awk’ is another great tool, albeit a bit more complex. Awk allows for the usual programming-like complexity of building your text-mangling solutions. [/su_note]

history > mygoldstash.txt 

Sidetrack: of naming things

One of the most well-known “you’d never believe it to be so hard” -problems in coding is naming things! Naming is required in many places: naming files, scripts, commands, variables, you name it!

In the above drill, I am running this superb Gauntlet game on my VPS, using node. So I named the entry point file as gsrv (for “gauntlet server”). Fair enough. But I have to admit already a few weeks down the memory lane it might be hard to remember this, especially if I had several node processes going on at the same time.

Enjoy! See you back later.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: