开发者

How to start a process that won't end when my ssh session ends?

开发者 https://www.devze.com 2023-01-23 04:32 出处:网络
Somehow this isn\'t yielded by a google search. I\'m scripting a server in node.js. I start the server by executing its script with the node program:

Somehow this isn't yielded by a google search.

I'm scripting a server in node.js. I start the server by executing its script with the node program:

node myserver.js

But the server staying up is dependent on my ssh session. How can I make thi开发者_如何学JAVAs (and all such processes) persistent? Init.d?


Use the nohup command:

From http://en.wikipedia.org/wiki/Nohup

nohup is a POSIX command to ignore the HUP (hangup) signal, enabling the command to keep running after the user who issues the command has logged out. The HUP (hangup) signal is by convention the way a terminal warns depending processes of logout.

Try this:

nohup node myserver.js &


Have you tried GNU screen? Using it, a process can continue to run when you end your ssh session. nohup is a standard *nix command that will allow you to do the same, albeit in a more limited way.


Use screen. Type screen from the terminal and then launch your process. If you disconnect you can reconnect to the ssh session, by typing 'screen -ls' (to see active screens) and 'screen -r' to reconnect.


The program needs to run in a daemonized mode. Here's a good post for doing this in Ubuntu.


nohup is good to run the job under. If the job is already running, you can try disown -h (at least in bash)

0

精彩评论

暂无评论...
验证码 换一张
取 消