How to Stop Node.js on Ubuntu and log out without stopping

1.1k Views Asked by At

I just put my node application up on my ubuntu server. I successfully started the program using

nodejs index.js

Now it gives me the "listening on *:3000"

The problem is that I am ssh'd into my ubuntu server, but the cursor is stuck under the "listening" line.

1) How can I close my ssh session and leave the node running? Should I have started the node with a different user?

2) Once I successfully close my ssh session and the node is still running. How can I stop node once I ssh back into the server?

3) Say I ssh into the server and start run my nodejs file, but I then want to do some other simple work for unrelated sites on the same server. Since the cursor is stuck after "listening" line, how can I go about doing anything else?

1

There are 1 best solutions below

0
On

I suggest that you use the screen program. Screen is a terminal multiplexer, which allows a user to access multiple separate terminal sessions inside a single terminal window or remote terminal session (such as when using SSH).

It can be started by typing screen on a terminal. Inside it, you can call node.js as usual. Then you press Ctrl+a and type d to detach it. To re-attach a detached session type screen -r.

More information can be found on the manual