Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I use putty and have an unreliable wireless connection, so I use screen to keep my work going. Often I'll get disconnected, and then I can't reattach my screen. I'll run screen -D -RR and it will just sit there indefinitely. I've tried ctrl+z to get my console back, followed by ps aux | grep screen and then kill -9 for all results, and then screen -D -RR again but I get the same results. I try any combination of d's and r's you care to mention, but still it just sits there. My screen is there, it just won't do anything, least of all resume.

Anybody have any tips or tricks or ideas for how to get my screen session to resume?

share|improve this question

6 Answers 6

up vote 12 down vote accepted

I've seen this when I drop a connection to an active screen then reconnect. Bug #27462 ("Reconnect stalls when original session is lost") describes the problem as I see it. What appears to happen is that screen is trying to notify the tty that holds it that it is about to leave, but since the tty is hung due to a dropped connection it has to wait for the timeout to happen (which is upwards of five minutes in some cases).

To fix it, I do this:

  • figure out which tty is holding on to the screen session ps -ef | grep screen | grep pty
  • find the login bash that is associated with that tty ps -ef | grep bash | grep $PTY
  • kill that bash kill -KILL $PID

This causes screen to complete its disconnect correctly, and lets you reconnect normally.

See here for an example script automating this somewhat.

share|improve this answer
    
ps -ef | grep screen | grep tty never prints anything because ps -ef | grep screen never returns anything with the string tty. –  Dave Aaron Smith Jan 22 '10 at 22:18
    
Actually the example script seems to do the trick. Thanks! –  Dave Aaron Smith Jan 22 '10 at 22:24
1  
Yeah, I meant 'pty', not 'tty'. –  David Mackintosh Jan 23 '10 at 2:59

I can't say I've ever had a problem with screen not coming back, no matter what type of connection I'm on. My usual method:

ssh myname@foo
screen -S sessionName
(do my work... get disconnected...)

ssh myname@foo
screen -d (just to make sure anything wasn't left attached)
screen -r sessionName
share|improve this answer
1  
For example screen -list returns 32322.mySession (Attached). Then I screen -d mySession. Then screen -list still returns 32322.mySession (Attached), and screen -r mySession returns There is no screen to be resumed matching daveSession. –  Dave Aaron Smith Jan 22 '10 at 22:03
    
did you try just "screen -d"? –  Jason Antman Jan 25 '10 at 20:37

I had a similar issue with my screen sessions. I name them and have them setup as multi-user sessions. What I found was that it was listing my sessions but telling me I had none to reconnect to. Then I tried:

screen -x <session_name>

It worked like a champ!

share|improve this answer

Is it possible that this bug is affecting you?

http://savannah.gnu.org/bugs/?27462

Can you try doing the workaround they recommend and seeing if it works?

share|improve this answer
    
The workaround didn't make much sense to me. My output of ps -ef |grep screen doesn't look like the example at all. –  Dave Aaron Smith Jan 22 '10 at 22:17

Soulrce:https://kb.iu.edu/data/ahrm.html

To see your existing screen sessions, enter:
  screen -list
This will display a list of your current screen sessions. For instance, if you had one attached screen, you would see:

         1636.pts-21.hostname      (Attached)

To detach an attached screen, enter:
  screen -D
If you have more than one attached screen, you can specify a particular screen to detach. For example, to detach the screen in the above example, you would enter:
  screen -D 1636.pts-21.hostname
share|improve this answer

Remove dead screens with screen -wipe.

share|improve this answer
    
I think that's the exact opposite of what he's trying to do. –  Chris S May 3 '12 at 17:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.