当我通过 ssh 登录到我的远程机器时,我想自动启动 gnu screen,所以我添加
exec screen
Run Code Online (Sandbox Code Playgroud)
到 .bash_profile 文件的末尾,然后我发现当我终止筛选时,我与 ssh 主机的连接也立即关闭。我怎样才能避免这种情况?
如果我想恢复屏幕(例如名为“旧屏幕”),因为我每次登录时都会开始屏幕,我面临的情况是我附加到“新屏幕”,我想重新附加到'旧屏幕'。如果我只是
screen -r old-screen
Run Code Online (Sandbox Code Playgroud)
我发现自己处于递归屏幕中,无法在“旧屏幕”中导航,因为所有快捷键都由“新屏幕”接收。如果我尝试退出当前屏幕,我与远程机器的连接也会立即丢失。
有什么解决办法吗?
screen -r您可以使用screen -R which 尝试恢复屏幕会话,而不是使用which 尝试恢复屏幕会话,如果不存在则创建一个新会话。
-r [pid.tty.host]
-r sessionowner/[pid.tty.host]
resumes a detached screen session. No other options (except com-
binations with -d/-D) may be specified, though an optional prefix
of [pid.]tty.host may be needed to distinguish between multiple
detached screen sessions. The second form is used to connect to
another user's screen session which runs in multiuser mode. This
indicates that screen should look for sessions in another user's
directory. This requires setuid-root.
-R attempts to resume the first detached screen session it finds. If
successful, all other command-line options are ignored. If no
detached session exists, starts a new session using the specified
options, just as if -R had not been specified. The option is set
by default if screen is run as a login-shell (actually screen uses
"-xRR" in that case). For combinations with the -d/-D option see
there.
Run Code Online (Sandbox Code Playgroud)
我个人倾向于使用screen -DRA.
-D -R Attach here and now. In detail this means: If a session is run-
ning, then reattach. If necessary detach and logout remotely
first. If it was not running create it and notify the user.
This is the author's favorite.
-A Adapt the sizes of all windows to the size of the current termi-
nal. By default, screen tries to restore its old window sizes
when attaching to resizable terminals (those with "WS" in its
description, e.g. suncmd or some xterm).
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3588 次 |
| 最近记录: |