43

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.
jww
  • 97,681
  • 90
  • 411
  • 885
Vansh Khurana
  • 657
  • 3
  • 9
  • 10

1 Answers1

58

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
Adrian Frühwirth
  • 42,970
  • 10
  • 60
  • 71
  • What will happen to my previous instance of the non-detached screen? I actually want the previous session to be resumed, so that I can see the progress – Vansh Khurana Aug 30 '13 at 08:47
  • In multi display mode both sessions are active and have write access (so you can interact with both instances and see the ouput in all connected instances) unless you make the session read-only (then the second instance can only watch). So you can continue with `-xr` as normal, and if you detach with the second instance the first instance will remain there and stay attached. But you can detach the first session if you wish by using `-dr` (see the manpage). – Adrian Frühwirth Aug 30 '13 at 08:56