Kill detached screen session [closed]

2019-01-29 14:44发布

I learned from somewhere a detached screen can be killed by

screen -X -S [session # you want to kill] kill

where [session # you want to kill] can be gotten from

screen -ls .

But this doesn't work. Anything wrong? What's the correct way?

11条回答
倾城 Initia
2楼-- · 2019-01-29 14:55
== ISSUE THIS COMMAND
[xxx@devxxx ~]$ screen -ls


== SCREEN RESPONDS
There are screens on:
        23487.pts-0.devxxx      (Detached)
        26727.pts-0.devxxx      (Attached)
2 Sockets in /tmp/uscreens/S-xxx.


== NOW KILL THE ONE YOU DONT WANT
[xxx@devxxx ~]$ screen -X -S 23487.pts-0.devxxx kill


== WANT PROOF?
[xxx@devxxx ~]$ screen -ls
There is a screen on:
        26727.pts-0.devxxx      (Attached)
1 Socket in /tmp/uscreens/S-xxx.
查看更多
Explosion°爆炸
3楼-- · 2019-01-29 14:55

Alternatively, while in your screen session all you have to do is type exit

This will kill the shell session initiated by the screen, which effectively terminates the screen session you are on.

No need to bother with screen session id, etc.

查看更多
兄弟一词,经得起流年.
4楼-- · 2019-01-29 14:56

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
查看更多
Rolldiameter
5楼-- · 2019-01-29 14:58

You can kill a detached session which is not responding within the screen session by doing the following.

  1. 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.

  2. Get attached to the detached screen session

    screen -r 20751.Melvin_Peter_V42
  3. Once connected to the session press Ctrl + A then type :quit

查看更多
家丑人穷心不美
6楼-- · 2019-01-29 15:04

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
查看更多
干净又极端
7楼-- · 2019-01-29 15:04

For me a simple

exit

works. This is from within the screen session.

查看更多
登录 后发表回答