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 dies. Is there anyway I can keep the process alive even with the terminal disconnected?
Edit 1
Actually, I tried nohup
, 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?
Edit 2 (on Feb, 2012)
There is a node.js
module, forever. It will run node.js server as daemon service.
nohup node server.js > /dev/null 2>&1 &
nohup
means: Do not terminate this process even when the stty is cut
off.> /dev/null
means: stdout goes to /dev/null (which is a dummy
device that does not record any output). 2>&1
means: stderr also goes to the stdout (which is already redirected to /dev/null
). You may replace &1 with a file path to keep a log of errors, e.g.: 2>/tmp/myLog
&
at the end means: run this command as a background task.