I'm new to screen and I'm trying to figure out how to detach from a session and reattach later. So far I've tried:
$screen
C-a z (within screen to detach)
$screen -r
So far so good but when I C-a z
to detach again, I see 2 screen processes running:
$ps
PID TTY TIME CMD
33145 ttys000 0:00.06 -bash
33176 ttys000 0:00.01 screen
33407 ttys000 0:00.01 screen -r
If I detach and reattach again I get another screen process, etc...
So, how can I reattach to the screen session without spawning a new process?
Thanks!
Try to detach within a screen:
to reattach:
screen -rd
(detaches the screen first if was attached)There is also:
screen -x
(attaches the screen again, so you can watch the screen with two sessions)C-a z
suspends your screen process. If your shell is bash, you can see the stopped process by runningjobs
and resume it withfg
. Detaching is a different concept.To detach from a session, use
C-a d
. You will still see the screen process in your process list, and you can list it by runningscreen -ls
. Resume withscreen -r
, but read the man page about the different ways to resume a running screen session.Congratulations on learning about screen! It's an amazing tool.