Published on

Managing Background Processes with Screen



This is a quick post on how to create, manage and delete background processes with screen


Screen allows you to run processes in a different session, so when you exit your terminal the process will still be running.


Install screen on the operating system of choice, for debian based systems it will be:

$ sudo apt install screen -y

Working with Screen

To create a screen session, you can just run screen or you can provide an argument to provide a name:

$ screen -S my-screen-session

Now you will be dropped into a screen session, run a ping:

$ ping

Now to allow the ping process to run in the background, send the commands to detach the screen session:

Ctrl + a, then press d

To view the screen session:

$ screen -ls
There is a screen on:	(Detached)
1 Socket in /var/folders/jr/dld7mjhn0sx6881xs_0s7rtc0000gn/T/.screen.

To resume the screen session, pass the screen id or screen name as a argument:

$ screen -r my-screen-session
64 bytes from icmp_seq=297 ttl=55 time=7.845 ms
64 bytes from icmp_seq=298 ttl=55 time=6.339 ms


To use a one liner to send a process as a detached screen session for scripting as an example, you can do that like this:

$ screen -S ping-process -m -d sh -c "ping"

Listing the screen session:

$ screen -ls
There is a screen on:	(Detached)

Terminating the screen session:

$ screen -S ping-process -X quit

Thank You

Thanks for reading, if you like my content, feel free to check out my website, and subscrube to my newsletter or follow me at @ruanbekker on Twitter.

Buy Me A Coffee