Screen is a great utility that can be used to manage multiple shells. For my purposes, I detatch shells that are doing a job and then come back to it from another session.
Let's use the following scenario:
I just installed a new Solaris machine and I want to patch it. It's late so I want to go home, but still be able to check the progress of the patch.
screen smpatch update
This opens a new screen sesion with the command smpatch running. Now I do the key command Ctrl-a Ctrl-d which detaches the screen from my currrnt shell. The process doesn't get suspended at all, but still is running in the background. Now I travel home, fire up my computer and ssh back into the new solaris box and check on my screen session.
Which basically grabs any current running screen sessions that I have running. There's different things this command will do under different scenarios:
- If there are no screen sessions, it will create one automatically.
- If there is only one screen session, it will attach this session to your screen.
- If there are more than one screen session then the command will exit out and print out the current screen sessions available. Then you can attach a specific screen by specifying the PID.
Then you are done! Since I only had one session runnnig with the smpatch, I was able to resume watching the command. Somtimes it's easier to create a new screen sesion first of just the shell, and then run your command into it.
There's many other commands you can use with screen (and also screenrc's). Do a man screen and see what else you can do! Here are mine:
- Ctrl-a Esc = allows you to go up and down the screen session and copy output.
- Ctrl-a Ctrl-a = Go back to last screen shell used.