murvinlai murvinlai - 1 year ago 134
Linux Question

How to run process as background and never die?

I connect to the linux server via putty SSH. I tried to run it as a background process like this:

$ node server.js &

However, after 2.5 hrs, the terminal becomes inactive and the process die. Is there anyway that I can keep the process alive even the terminal disconnected?


Help, please!

Actually, I tried
but as soon as I close the Putty SSH terminal or unplug my internet, the server process stops right away.

Is there anything I have to do in Putty?

Update on 2012 FEB: There is a node.js module, forever. It will run nodejs server as daemon service.

Good. :)

Answer Source

Simple solution (if you are not interested in coming back to the process, just want it to keep running):

nohup node server.js &

Powerful solution (allows you to reconnect to the process if it is interactive):


Also consider the newer alternative to screen, tmux.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download