Linux 如何强制从另一个 SSH 会话中分离 Screen?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20807696/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I force detach Screen from another SSH session?
提问by T. Brian Jones
I had Screen running inside an SSH session. Terminal froze. After restarting Terminal, that Screen session still thinks it's attached. Maybe it is. Perhaps I don't really know what that means.
我在 SSH 会话中运行 Screen。终端冻结。重新启动终端后,该 Screen 会话仍然认为它已附加。也许是。也许我真的不知道这意味着什么。
I'd like to attach to that Screen session from a fresh SSH login. I do not want to kill that Screen session as important things are happening over there. : )
我想从新的 SSH 登录附加到该 Screen 会话。我不想终止那个 Screen 会话,因为那里正在发生重要的事情。:)
The options I think I have ( none of which I know how to solve ):
我认为我拥有的选项(我都不知道如何解决):
- How do I detach that Screen session?
- How do I kill the SSH session that that Screen session is attached to?
- 如何分离该 Screen 会话?
- 如何终止该 Screen 会话附加到的 SSH 会话?
采纳答案by Matt S.
As Jose answered, screen -d -r
should do the trick. This is a combination of two commands, as taken from the man page.
正如何塞回答的那样,screen -d -r
应该可以解决问题。这是两个命令的组合,取自手册页。
screen -d
detaches the already-running screen session, and screen -r
reattaches the existing session. By running screen -d -r
, you force screen to detach it and then resume the session.
screen -d
分离已经运行的屏幕会话,并screen -r
重新附加现有的会话。通过运行screen -d -r
,您可以强制 screen 分离它,然后恢复会话。
If you use the capital -D -RR
, I quote the man page because it's too good to pass up.
如果您使用大写字母-D -RR
,我会引用手册页,因为它太好了,不容错过。
Attach here and now. Whatever that means, just do it.
Note: It is always a good idea to check the status of your sessions by means of "screen -list".
在这里和现在附上。不管这意味着什么,就去做吧。
注意:通过“screen -list”检查会话状态总是一个好主意。
回答by Jose Luis Martin
try with screen -d -r
or screen -D -RR
尝试screen -d -r
或screen -D -RR
回答by user10874456
Short answer
简答
- Reattach without ejecting others:
screen -x
- Get list of displays:
^A
*
, select the one to disconnect, pressd
- 重新连接而不弹出其他人:
screen -x
- 获取显示列表:
^A
*
,选择要断开连接的一个,按d
Explained answer
解释的答案
Background:When I was looking for the solution with same problem description, I have always landed on this answer. I would like to provide more sensible solution. (For example: the other attached screen has a different size and a I cannot force resize it in my terminal.)
背景:当我寻找具有相同问题描述的解决方案时,我总是落在这个答案上。我想提供更明智的解决方案。(例如:另一个附加屏幕的大小不同,我无法在我的终端中强制调整它的大小。)
Note:
PREFIX
is usually^A
=ctrl+a
注意:
PREFIX
通常是^A
=ctrl+a
Note:the displaymay also be called:
- "user front-end"(in
at
command manual in screen)- "client"(tmux vocabulary where this functionality is
detach-client
)- "terminal"(as we call the window in our user interface) /depending on
注:该显示器也可以称为:
- “用户前端”(
at
在屏幕中的命令手册中)- “客户端”(此功能所在的 tmux 词汇表
detach-client
)- “终端”(正如我们在用户界面中所说的窗口)/取决于
1. Reattach a session: screen -x
1. 重新连接会话:screen -x
-x
attach to a not detached screen session without detaching it
-x
附加到未分离的屏幕会话而不分离它
2. List displaysof this session: PREFIX
*
2.列出显示本次会议:PREFIX
*
It is the default key binding for: PREFIX
:displays
.
Performing it within the screen, identify the other displaywe want to disconnect (e.g. smaller size). (Your current displayis displayed in brighter color/bold when not selected).
它是以下的默认键绑定:PREFIX
:displays
。在屏幕内执行它,确定我们要断开连接的其他显示器(例如较小的尺寸)。(您当前的显示器在未选择时以更亮的颜色/粗体显示)。
term-type size user interface window Perms
---------- ------- ---------- ----------------- ---------- -----
screen 240x60 you@/dev/pts/2 nb 0(zsh) rwx
screen 78x40 you@/dev/pts/0 nb 0(zsh) rwx
Using arrows ↑
↓
, select the targeted display, press d
If nothing happens, you tried to detach your own display and screen will not detach it. If it was another one, within a second or two, the entry will disappear.
使用箭头↑
↓
,选择目标显示器,按d
如果没有任何反应,您尝试分离自己的显示器,屏幕将不会分离它。如果是另一个,在一两秒钟内,该条目将消失。
Press ENTER
to quit the listing.
按ENTER
退出列表。
Optionally:in order to make the content fit your screen, reflow: PREFIX
F
(uppercase F)
可选:为了使内容适合您的屏幕,回流:(PREFIX
F
大写 F)
Excerpt from man page of screen:
摘自屏幕手册页:
displays
Shows a tabular listing of all currently connected user front-ends (displays). This is most useful for multiuser sessions. The following keys can be used in displays list:
mouseclick
Move to the selected line. Available when "mousetrack" is set to on.space
Refresh the listd
Detach that displayD
Power detach that displayC-g
,enter
, orescape
Exit the list
显示
显示所有当前连接的用户前端(显示)的表格列表。这对于多用户会话最有用。以下键可用于显示列表:
mouseclick
移动到选定的行。当“鼠标跟踪”设置为打开时可用。space
刷新列表d
拆开那个显示器D
电源分离那个显示器C-g
,enter
, 或escape
退出列表
回答by Vimal Surendran
Try the command screen -d -r
.
This worked for me..!
试试这个命令screen -d -r
。
这对我有用..!