Leaving Screen Terminal Session There are 2 (two) ways to leaving the screen. First, we are using “Ctrl-A” and “d” to detach the screen. Second, we can use the exit command to terminating the screen. You also can use “Ctrl-A” and “K” to kill the screen.
On the command prompt, type screen . Run the desired program. Use the key sequence Ctrl-a + Ctrl-d to detach from the screen session. Reattach to the screen session by typing screen -r .
To start a screen session, you simply type screen within your ssh session. You then start your long-running process, type Ctrl+A Ctrl+D to detach from the session and screen -r to reattach when the time is right. Once you have multiple sessions running, reattaching to one then requires that you pick it from the list.
"kill" will only kill one screen window. To "kill" the complete session, use quit
.
$ screen -X -S [session # you want to kill] quit
For dead sessions use: $ screen -wipe
You can kill a detached session which is not responding within the screen session by doing the following.
Type screen -list
to identify the detached screen session.
~$ screen -list There are screens on: 20751.Melvin_Peter_V42 (Detached)
Note: 20751.Melvin_Peter_V42
is your session id.
Get attached to the detached screen session
screen -r 20751.Melvin_Peter_V42
Once connected to the session press Ctrl + A then type :quit
List screens:
screen -list
Output:
There is a screen on:
23536.pts-0.wdzee (10/04/2012 08:40:45 AM) (Detached)
1 Socket in /var/run/screen/S-root.
Kill screen session:
screen -S 23536 -X quit
It's easier to kill a session, when some meaningful name is given:
//Creation:
screen -S some_name proc
// Kill detached session
screen -S some_name -X quit
You can just go to the place where the screen session is housed and run:
screen -ls
which results in
There is a screen on:
26727.pts-0.devxxx (Attached)
1 Socket in /tmp/uscreens/S-xxx. <------ this is where the session is.
And just remove it:
cd /tmp/uscreens/S-xxx
ls
26727.pts-0.devxxx
rm 26727.pts-0.devxxx
ls
The uscreens
directory will not have the 26727.pts-0.devxxx
file in it anymore. Now to make sure just type this:
screen -ls
and you should get:
No Sockets found in /tmp/uscreens/S-xxx.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With