Question

regarding running terminal commands on vps

  • Posted on January 31, 2015
  • bet4rsAsked by bet4rs

regarding running terminal commands on vps (for e.g. “node server.js”) I can run those commands using putty via my pc, but when I close putty, the node closes too. Can it be that I close my putty and the node still continues to run?


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

You can do

screen -S node

and then execute your command.

Then, press control-d

After that, you can close putty.

If you want to go back to your screen session, do screen -r node

You can then do control-c to stop it, etc.

It depends on the kind of code you run. Some applications run inside your session, so when you disconnect, they stop. Others run on the background, and continue to do so if you disconnect.

Running “node server.js” is a command connected to your session, and it will stop once you disconnect. If that’s not what you want, you need to set up some kind of service or daemon that will run your for you after you disconnect.