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

Somehow it does not lend itself to google search.

I am writing a server in node.js. I start the server by executing its script using the node program:

node myserver.js

But the standby server depends on my ssh session. How can I make this (and all such processes) permanent? Init.d?

+4
source share
5 answers

Use the nohup command:

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

nohup is a POSIX command to ignore the HUP (hangup) signal, allowing the command to continue to work after the user logs out of the system that issues the command. The HUP (hang) signal is consistent with how the terminal warns of dependent logout processes.

Try the following:

 nohup node myserver.js & 
+11
source

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

+3
source

Use the screen. Enter the screen from the terminal and then start the process. If you disconnect, you can connect to the ssh session by typing "screen -ls" (to see the active screens) and "screen -r" to reconnect.

+1
source

The program should start in dismantled mode. Here is a good post for this on Ubuntu .

0
source

nohup is suitable for work. If the task is already running, you can try disabling -h (at least in bash)

0
source

Source: https://habr.com/ru/post/901816/