Here’s the situation, you are using bash’s Screen command because you don’t want your flakey internet connection to affect whatever you are working on, and sure enough, the connection drops. Sometimes, when you try to re-attach to this screen session you are told that the screen session is still attached…
~$ screen -r '1234.somescreensession'
There is a screen on:
1234.somescreensession (Attached)
There is no screen to be resumed matching 1234.somescreensession.
How annoying.
UPDATE:
Here is a simple way to take back that screen session.
screen -D -r '1234.somescreensession'
Kudos to Donncha O’Caoimh
Here is a way a longer way to remove the process that is attached to that screen session, so you can reattach to it and continue with whatever you were doing.
- figure out which tty is holding on to the screen session by typing into terminal
ps -ef | grep screen | grep tty
- result of this should be something like
testdev 5760 5688 0 12:31 ttyp1 00:00:00 screen -r 1234.somescreensession
- in this case the tty is 5688, use this to find the login bash that is associated with that tty
ps -ef | grep bash | grep 5688
- result of this should be something like
testdev 5688 5687 0 12:28 ttyp1 00:00:00 -bash
- kill process
kill -9 5687
Now you should be free to re-attach to this screen session.
Kudos to David Mackintosh
Even better, I always do
screen -D -r
which detaches the screen session!Thanks Donncha, that is a much simpler way. Updated post.
I’ve also found you don’t have to type the entire thing.. just the numbers @ the start.
when you start a screen session with a name ‘screen -S yourprogramname’ you can reattach your detached screen by call it with ‘screen -r yourp’. So you don’t have to type any numbers..
Thanks , Able to attache my screen back .
Thank you and thank you again. -D saved the day for me. đŸ™‚
Helpful… Thanks!
wow.. i sepnd like 15-20 min to figue this out how to do it, then finally searched this forum.. and able to reattached it :)..
thanks a lot!
Thank you for sharing your knowledge. Saved my night!
Thanks for this! Great Post – saved me a lot of trouble!
Thank you!!
thanks for screen -D -r đŸ™‚
It didn’t help me in any way…. However Typing “Exit”, did đŸ™‚
if you have a single screen session running and the connection dropped, typing “screen -x” will attach you directly to that single screen session
Thank You , it helped me
Very good info !! Thank you đŸ™‚
screen -D -r ‘1234.somescreensession’ … helped me. Thanks.
Thanks man.
Thanks for the help man.