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.
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.
- 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.
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.
Have any questions or suggestions? Leave a comment down below.
Top comments (5)
Later how we can see the log?
I mean after making it runing in background, hhow to see that again?
I was searching a way to see the logs of a specific process but I still can't get it.
How we know if it's running?
I think you can watch if your process is running with -> screen -ls