Search code examples
node.jsubuntu-server

How to stop a node program while in another command window


I have an ubuntu server running with 2 node websites on it and I keep closing the terminals that start the app so I cannot shut the app down to make changes, I end up restarting the server.

How can I see what node instances are running and then stop them, or how do I stop a node instance through programming and I'll just make a button that kills the node instance. Either way...


Solution

  • If you dont want to use PM2 or systemd you can get the list of all the node.js instances running using

    ps -aux | grep node
    

    once you have the list of all nodejs processes you can kill any process using kill command

    kill "Process ID goes here"