Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS EC2: keep running node.js after exit console

I use aws ec2 to host web server with node.js and apache.

So far, I always need to login ec2 through terminal to run npm start.

I wanna make it keep running even if Im not on terminal. How am I supposed to setup for it?

I turned on https, but nothing happened.

I appreciate it in advance.

like image 216
Poipoi Avatar asked Oct 15 '25 16:10

Poipoi


1 Answers

One option is using the screen command:

screen

You will reach a new bash prompt for that screen. Run your app.

To detach the screen, press Ctrl+A, then D to detach from that screen.

To reattach screen when you next SSH in, use

screen -ls 

to see detached screens and use

screen -r xxxxx

with the screen number to reattach that screen.

like image 96
NodeNewb Avatar answered Oct 18 '25 07:10

NodeNewb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!