1

screen -list shows

There are screens on:
    9531.pts-0.ubuntu   (03/02/2011 12:43:34 PM)    (Detached)
    2101.pts-0.ubuntu   (03/02/2011 12:39:17 PM)    (Attached)
    2219.pts-0.ubuntu   (03/02/2011 11:20:56 AM)    (Attached)
3 Sockets in /var/run/screen/S-bond.

but when I type

screen -r 2101.pts-0.ubuntu
There is a screen on:
    2101.pts-0.ubuntu   (03/02/2011 12:39:16 PM)    (Attached)
There is no screen to be resumed matching 2101.pts-0.ubuntu.

Here I can not get back the the screen 2101.pts-0.ubuntu and infact I get exited. Where as if I do

screen -r 9531.pts-0.ubuntu
[detached from 9531.pts-0.ubuntu]

then above you can see I went inside that session and came out and I can do it again and again.But with other sessions same is not the case? SO what mistake am I doing?

Registered User
  • 1,463
  • 5
  • 18
  • 37

2 Answers2

5

As you can see from screen -list, that screen session is currently attached. You cannot attach to it from somewhere else without detaching it first. You can do this by adding the -d option, like screen -d -r 2101.pts-0.ubuntu. There is more information in the GNU Screen manual. Here is an excerpt:

-r [pid.tty.host]
-r sessionowner/[pid.tty.host]
resumes a detached screen session. No other options (except combinations 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

-d|-D [pid.tty.host]
does not start screen, but detaches the elsewhere running screen session. It has the same effect as typing "C-a d" from screen's controlling terminal. -D is the equivalent to the power detach key. If no session can be detached, this option is ignored. In combination with the -r/-R option more powerful effects can be achieved:

-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.

-x Attach to a not detached screen session. (Multi display mode).

Note: It is always a good idea to check the status of your sessions by means of "screen -list".

sciurus
  • 12,678
  • 2
  • 31
  • 49
2

Call the doctor!

screen -dr 2101.pts-0.ubuntu
Cakemox
  • 25,209
  • 6
  • 44
  • 67