Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a screen session on a server. I lost wireless connection. When reconnecting to the server, the screen session is shown as "Attached" in "screen -ls". I cannot detach it by "screen -d session#" however, neither can I kill it by "screen -X -S session# quit". How can I deal with it?

Thanks and regards!

share|improve this question
up vote 4 down vote accepted

The brute-force way of doing it is:

ps waux | grep screen

Find the pid and then do a kill -9 on it... Otherwise, try these command-line arguments to screen:

-D [pid.sessionname] Do not start screen, but instead detach a screen session running elsewhere (see section 8.1 Detach). '-d' has the same effect as typing C-a d from the controlling terminal for the session. '-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. 

Note: It is a good idea to check the status of your sessions with screen -list before using this option.
share|improve this answer
    
Thanks. But ps waux | grep screen does not show the screen session. screen -D is also stuck. – Tim Mar 8 '10 at 23:12
1  
Have you tried "screen -D -RR <sessionname>" ? – Trevoke Mar 9 '10 at 13:53
    
"screen -D -RR <sessionname>" worked when "screen -D -RR" didn't, even when I had only one screen session in "screen -ls". Thanks! – madh Apr 5 '11 at 19:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .