Search code examples
shellgnu-screen

How to resume screen?


Let's say I have many screens open, and I would like to resume to a particular screen session using 'screen -r ' this is wahat i get when I execute screen -r There are several suitable screens on:

12670.pts-8.b-dev03 (Detached)
23662.pts-9.b-dev03 (Detached)
502.pts-1.b-dev03   (Attached)
19972.pts-1.b-dev03 (Detached)
9414.pts-24.b-dev03 (Attached)
16607.pts-1.p-dev03 (Detached)
3015.pts-2.b-dev03  (Detached)
14313.pts-18.b-dev03    (Attached) 
Type "screen [-d] -r [pid.]tty.host" to resume one of them.

How do I resume one of them, lets say the last one which is attached. I have tried -

screen -r 14313.pts-18.b-dev03
 There is a screen on:
14313.pts-18.b-dev03    (Attached)
There is no screen to be resumed matching 14313.pts-18.b-dev03.

Solution

  • The wording is a little unlucky - this happens because there still is a screen session attached to 14313.pts-18.b-dev03 and you cannot simply "resume" a non-detached session. You need to use the -x option in addition to attaching to this session with a second screen instance (or, alternatively, detach the existing session first):

    -x

      Attach to a not detached screen session. (Multi display mode).
    
    $ screen -xr 14313
    

    If you wish to detach the first session instead:

    -d -r

      Reattach a session and if necessary detach it first.
    
    $ screen -dr 14313