With the use of VPN, firewalls, etc. even a reliable connection can disappear without warning, sometimes rendering hours of testing or other work worthless.
Fortunately, the Controller of your applogic grid includes "screen," a valuable "terminal multiplexor" that allows you to manage multiple sessions within the same ssh session. A happy circumstance to this is that screen detaches your work from your connection so that programs you start, scripts you run, and other things that normally rely on your solid connection to the controller are able to continue, even when you lose connectivity to the remote controller.
The diagram following shows the relationship between the various elements of screen. As users login and run screen, they create "socket" files in /tmp/screens/S-root. Multiple users create multiple sockets. These sockets are persistent when you lose contact with the controller for whatever reason. Further, each socket can support multiple windows, i.e., session that can run programs and scripts independently of the other windows supported by the socket. When connected to the socket, can switch between the windows and conduct multiple operations in parallel.
Starting Screen
As soon as you log into the controller, enter "screen." This puts you into screen's subshell. At that point if you are disconnected, there's a good chance your work, running programs, etc. will continue in your absence.
Note: Screen is not available in the grid console; you need the full Linux access as is provided by grid_maintainer to use it.
Once you have started screen, you are able to safely shutdown or otherwise lose your ssh session without affecting the programs running in that session. You can go about your business, and if something happens to your connection (i.e., vpn timeout for example), you can log back in once resolved and type
> screen -list
There is a screen on:
17172.pts-0.ewing2-3519 (Detached) 1 Socket in /temp/screens/S-root/.
That screen is your running session, preserved. You simply have to attach to it like this:
> screen -r
Will attach your ssh session to the first attached screen it finds.
> screen -list
There is a screen on:
17172.pts-0.ewing2-3519 (Attached) 1 Socket in /tmp/screens/S-root.
The session is now reattached as shown in the list report and you should have access to the programs originally running there once again.
Not only does screen protect your work from unintended disconnection, it allows you to manage multiple windows from the same ssh session.
To discern between a window and a screens, screen are separate attachable terminal sessions. When a user instance runs screen, it creates a screen file in the socket directory. If someone happens to log in again with the same account and runs screen, there will be two screen files when you run screen –list.
You can move between THESE sessions by using:
> screen -x <session_name>
To add another window session, press Control+a c (c for "create") .
Use Control+a Control+a to switch between the two windows; each window will be able to run a different program.
It is possible to have the option of running screen on connection to the controller. This snippet of code can be added to root's .bash_profile at the end:
read -p "Do you want to run screen? " answer case $answer in [yY] | [yY][Ee][Ss] ) screen ;; [nN] | [nN][Oo] ) echo "Screen skipped."; ;; *) echo "bad input, run "screen" manually if you need it." ;; esac
For a more in-depth look at screen, see the documentation at http://www.gnu.org/software/screen/manual/screen.pdf .
For a quick cheat sheet of screen commands, see http://neophob.com/2007/04/gnu-screen-cheat-sheet/ .
|
Copyright © 2012 CA.
All rights reserved.
|
|