I'm working on a remote debian jessie server I have started a screen session, started running a script, then been disconnected by a network timeout.

Now i've logged in and want to resume the session

This is what i see when i list the screens

$ screen -ls
There are screens on:
    30608.pts-8.myserver    (11/03/2015 08:47:58 AM)    (Attached)
    21168.pts-0.myserver    (11/03/2015 05:29:24 AM)    (Attached)
    7006.pts-4.myserver (10/23/2015 09:05:45 AM)    (Detached)
    18228.pts-4.myserver    (10/21/2015 07:50:49 AM)    (Detached)
    17849.pts-0.myserver    (10/21/2015 07:43:53 AM)    (Detached)
5 Sockets in /var/run/screen/S-me.

It seems i'm attached to two screens at the same time

Now i want to start the session i was running before to see the results of my script

$ screen -r 30608.pts-8.myserver
There is a screen on:
    30608.pts-8.OpenPrescribing (11/03/2015 08:47:58 AM)    (Attached)
There is no screen to be resumed matching 30608.pts-8.myserver.

Why can't i reattach?

I have the same problem with the other screen.

$ screen -r 21168.pts-0.myserver
There is a screen on:
    21168.pts-0.OpenPrescribing (11/03/2015 05:29:24 AM)    (Attached)
There is no screen to be resumed matching 21168.pts-0.myserver.
Best Answer


The session is still on another terminal The server hasn't detected the network outage on that connection: it only detects the outage when it tries to send a packet and gets an error back or no response after a timeout, but this hasn't happened yet. You're in a typical situation where the client detected the outage because it tried to send some input and failed but the server is just sitting there waiting for input The server - eventually - will send a keepalive packet and it will detect that the connection is dead

In the meantime, use the -d option to detach the screen session from the terminal where it's in.

screen -r -d 30608

screen -rd is pretty much the standard way to attach to an existing screen session.