如果存在GNU Screen连接,如果不存在则创建

bsw*_*ton 16 gnu-screen

目前,我正在iPad上使用GNU屏幕,并在连接丢失的情况下利用屏幕作为安全措施.目前,我只是将屏幕-S ipad作为第一个命令运行,但有没有办法让它自动连接到旧的ipad会话(如果存在的话)(如果不存在则创建它)?我的一个警告是,我想在一个命令中自动执行此操作.

Kur*_*tal 24

-D -R选项将屏幕尝试分离或在必要时创建.

screen -D -R -S ipad
Run Code Online (Sandbox Code Playgroud)

我建议您查看-d|D -r|-R|-RR屏幕手册中的所有选项,因为有许多类似的结果.

-d -r
    Reattach a session and if necessary detach it first. 
-d -R
    Reattach a session and if necessary detach or even create it first. 
-d -RR
    Reattach a session and if necessary detach or create it. Use the first session if more than
    one session is available. 
-D -r
    Reattach a session. If necessary detach and logout remotely first. 
-D -R
    Attach here and now. In detail this means: If a session is running, 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. 
-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". 
Run Code Online (Sandbox Code Playgroud)