SCREEN – Keep a process running after closing SSH connection

2 min read

There are many reasons why you would like to keep a process running even if you close your SSH session.

Here are a few examples:

  • Your working day is going to be over soon and you are running a huge database import that’s taking a long time to complete, you would not want to stay and wait for the import to complete but just hand over the task to the next person on shift
  • You are downloading a huge file and it’s going to take a good few hours, you would not want to leave your terminal open and wait, or even worse, you don’t want to start all over again in case that your internet connection drops

What I usually do in such cases is to use the screen command and run the processes in a screen session. That way I could detach from the screen session and close my SSH connection and the process would still run allowing me or other people to attach to the session later on and follow up on the process.

Here’s a quick introduction to how to use screen!

According to the official documentation screen is a full-screen window manager that multiplexes a physical terminal between several processes, typically interactive shells. When screen is called, it creates a single window with a shell in it where you could run commands as normal.

I’ve noticed that in most cases screen is installed by default, so to check if you have screen installed you could run the following:

screen --version

If you get command not found, then you could install screen by running:

  • For Ubuntu and Debian:
sudo apt update -y
sudo apt install screen
  • On CentOS:
yum update -y
sudo yum install screen

Once you have screen installed, to start a new screen session run:


This would spin up a new screen and you would be attached to it automatically, inside the screen session run your script.

After that to detach from the screen session press CTRL+a+d.

If you need to attach back to the screen session run and check on your process just run:


If you’ve forgotten the name of your screen session or if you’ve not set a name, you could list all available screen sessions by running:

screen -ls

This is just a really brief introduction on how to use screen, I would recommend checking out the official documentation as well:

Hope that this helps!

We want to hear your thoughts about this. Is there anything in particular that you love about it? What can we do to improve our services and experience? Leave a comment below or open a ticket on our helpdesk and we’ll personally review all suggestions and feedback. 

About Servercheap.NET

Since it was founded in 2015, Servercheap has always strived to provide its clients with enterprise-level performance at an unbeatable cost. Servercheap offers a wide range of customizable hybrid and virtual private server hosting services. All Servercheap clients enjoy a 99.9% uptime SLA and 24/7 rapid response support team.
At Servercheap, our core directive has always been to provide our clients with the best services and infrastructure possible, whether you’re hosting a game server, a high-intensity database, a development environment, or anything in-between.
For more information, visit

Leave a Reply

Your email address will not be published. Required fields are marked *