I have a few windows in a single screen
session and then I want to detach my session. There is no problem with that.
But I can't find a way to restore all windows within my previously detached session. I can see that I can restore just one of them by ID.
But how can I reattach exact the same session environment with all the windows in it?
--
Updated:
If I type screen -d -r, this is what is says:
There are several suitable screens on:
21074.pts-7.atx (05/29/2010 02:26:32 PM) (Attached)
3420.pts-3.atx (05/29/2010 12:16:41 AM) (Detached)
Type "screen [-d] -r [pid.]tty.host" to resume one of them.
How can I reattach all of them?
To start a screen session, you simply type screen within your ssh session. You then start your long-running process, type Ctrl+A Ctrl+D to detach from the session and screen -r to reattach when the time is right.
Ctrl-a + r: It reattach a detached screen session.
There are 2 (two) ways to leaving the screen. First, we are using “Ctrl-A” and “d” to detach the screen. Second, we can use the exit command to terminating the screen. You also can use “Ctrl-A” and “K” to kill the screen.
screen -d -r : Reattach a session and if necessary detach it first.
This will reattach your old session, will all its windows. If your session is still attached, it will detach it before attaching it to the current terminal. This is quite useful when for example you have kept your screen session in an ssh terminal on another computer.
To reattach all previously detached sessions I use this little script.
#!/bin/sh
for line in `screen -ls | grep Detached | awk '{print $1}'`; do
xdotool key control+shift+t type "screen -r $line"
xdotool key KP_Enter
done
"control+shift+t" happened to be a shortcut in my terminal for opening a new tab and it may be different shortcut in yours.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With