Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 5, 2022 09:59 am GMT

How to keep EC2 instance running after SSH is terminated?

In this blog post, I'm going to list a few commands that will help you to keep the EC2 instance running after SSH is terminated.

Author

Akhilesh Thite

Linux & Mac users

First, Log in to the server with your SSH key.

  • To keep the server running in background, use the following command.
screen -d -m

Let's assume you have a python web application, then your command would look like this:

screen -d -m python app.py

Or if you're using node, then your command would look like this:

screen -d -m npm start
  • To list the available screens, use the following command.
screen -ls
  • To restart the session, use the following command.
screen -r [session restart]
  • To quit the session, use the following command.
screen -X -S [session you want to kill] quit

Windows (PuTTY) users

First, SSH into your remote box. Type screen, then start the process you want.

  • Press Ctrl-A then Ctrl-D. This will detach your screen session but leave your processes running. Now, you can log out of the remote box.

  • If you want to come back later, log on again and type screen -r, this will resume your screen session and you can see the output of your process.

Thank you!


Original Link: https://dev.to/akhileshthite/how-to-keep-ec2-instance-running-after-ssh-is-terminated-45k8

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To