终止分离的屏幕会话

发布于 2024-08-06 16:18:03 字数 196 浏览 9 评论 0原文

杀死分离的屏幕,

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

我从某处了解到,可以通过从[您想要杀死的会话#]获得的位置来

screen -ls

但这不起作用。有什么问题吗?正确的方法是什么?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

GRAY°灰色天空 2024-08-13 16:18:03

“kill”只会杀死一个屏幕窗口。要“终止”整个会话,请使用quit

示例

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

对于死会话使用:
$ 屏幕-擦拭

"kill" will only kill one screen window. To "kill" the complete session, use quit.

Example

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

For dead sessions use:
$ screen -wipe

你在我安 2024-08-13 16:18:03

您可以通过执行以下操作来终止在屏幕会话中没有响应的分离会话。

  1. 输入 screen -list 来识别分离的屏幕会话。

    ~$ screen -list  
        屏幕上有:  
             20751.Melvin_Peter_V42(分离)  
    
    
    

    注意:20751.Melvin_Peter_V42 是您的会话 ID。

  2. 附加到分离的屏幕会话

    screen -r 20751.Melvin_Peter_V42
  3. 连接到会话后,按 Ctrl + A,然后输入 :quit

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

香草可樂 2024-08-13 16:18:03

列出屏幕:

screen -list

输出:

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.

终止屏幕会话:

screen -S 23536 -X 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
梦在深巷 2024-08-13 16:18:03

当给出一些有意义的名称时,终止会话会更容易:

//Creation:
screen -S some_name proc
// Kill detached session
screen -S some_name -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
在巴黎塔顶看东京樱花 2024-08-13 16:18:03

您可以转到屏幕会话所在的位置并运行:

 screen -ls

这会导致

 There is a screen on:
         26727.pts-0.devxxx      (Attached)
 1 Socket in /tmp/uscreens/S-xxx. <------ this is where the session is.

并删除它:

  1. cd /tmp/uscreens/S-xxx
  2. ls
  3. 26727.pts-0.devxxx
  4. rm 26727.pts-0.devxxx
  5. ls

uscreens 目录不会有 < code>26727.pts-0.devxxx 文件不再存在。现在确保只需输入:

screen -ls

,您应该得到:

在 /tmp/uscreens/S-xxx 中找不到套接字。

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:

  1. cd /tmp/uscreens/S-xxx
  2. ls
  3. 26727.pts-0.devxxx
  4. rm 26727.pts-0.devxxx
  5. 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.

池予 2024-08-13 16:18:03
screen -wipe

应清理所有屏幕会话。

screen -wipe

Should clean all dead screen sessions.

居里长安 2024-08-13 16:18:03

将其添加到您的 ~/.bashrc 中:

alias cleanscreen="screen -ls | tail -n +2 | head -n -2 | awk '{print $1}'| xargs -I{} screen -S {} -X quit"

然后使用 cleanscreen 清理所有屏幕会话。

add this to your ~/.bashrc:

alias cleanscreen="screen -ls | tail -n +2 | head -n -2 | awk '{print $1}'| xargs -I{} screen -S {} -X quit"

Then use cleanscreen to clean all screen session.

聽兲甴掵 2024-08-13 16:18:03

对我来说一个简单的

exit

作品。这是来自屏幕会话内的。

For me a simple

exit

works. This is from within the screen session.

酒与心事 2024-08-13 16:18:03

要终止所有分离的屏幕会话,请将此函数包含在您的.bash_profile中:

killd () {
for session in $(screen -ls | grep -o '[0-9]\{5\}')
do
screen -S "${session}" -X quit;
done
}

要运行它,请调用killd

To kill all detached screen sessions, include this function in your .bash_profile:

killd () {
for session in $(screen -ls | grep -o '[0-9]\{5\}')
do
screen -S "${session}" -X quit;
done
}

to run it, call killd

ぶ宁プ宁ぶ 2024-08-13 16:18:03
== 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.
== 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.
忆依然 2024-08-13 16:18:03

或者,在屏幕会话中,您只需键入 exit

这将终止屏幕启动的 shell 会话,从而有效地终止您所在的屏幕会话。

无需担心屏幕会话 ID 等。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文