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?
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:
ps -ef | grep screen | grep pty
ps -ef | grep bash | grep $PTY
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.
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!
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:
If you're smart like me, you were trying to resume a screen session started as
root
with the regular user account. Found this out withls /var/run/screen
showing me a directory forroot
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?
Soulrce:https://kb.iu.edu/data/ahrm.html
I occasionally have the same problem (screen -r -d not resuming, non-responsive). To fix, find the terminal (tty/pty) associated with the screen session:
Find the terminal listed (in this example pts-51) :
Kill the processes on that terminal (usually your shell) :
run ps again to make sure it is gone. If not :
On my server (gnu/linux), I sometimes will have to kill -9 several times until it dies.
After all the processes on that tty are gone, screen should resume correctly:
Remove dead screens with
screen -wipe
.