23

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

4

1 回答 1

33

这些-D -R选项将使屏幕在必要时尝试分离或创建。

screen -D -R -S ipad

我建议您查看-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". 
于 2012-05-03T15:15:45.277 回答