Linux – detach screen session

gnu-screenlinux

I have an attached screen session where I am running some jobs. I closed its terminal without detaching it because it does not respond suddently. Now by screen -ls I can see it is still attached. But I cannot reattach it without detaching it first, however detaching it takes a very long time and still is not finished yet.

  bash-3.2$ screen -ls  
  There are screens on:  
   14493.ssh2others (Attached)  
  1 Socket in /tmp/uscreens/S-tim.  

  bash-3.2$ screen -r 14493  
  There is a screen on:  
   14493.ssh2others (Attached)  
  There is no screen to be resumed matching 14493.  
  bash-3.2$ screen -d 14493  

I wonder why it takes so long and is not finished detaching yet?

Since my jobs are running in the screen session, I am afraid killing it will kill my jobs as well. So what can I do to detach and reattach it now?

Thanks!

Best Answer

In some cases, your previous screen session may not have detached properly when you lost your connection for example. If this happens, you can still detach your session manually.

To see your existing screen sessions, enter:

screen -list

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:

screen -D 14493.ssh2others

Once you've done this, you can resume the screen by entering the screen -r command.