Sunday, September 14, 2008

Screen -A very useful unix tool to work with remote system

Sometimes on remote server I have to ssh and run some long running operations. Like I have to take a dump on USA server while I am in Bangladesh, or have to backup or restore operation on remote server. If disk is slow and/or database size is big then this process may take hours after hours.

During this time if my session terminates for example network down, power outage then my whole process abnormally shutdown and I have to start from first again.

Unix screen tool in this case really makes our life easy.

screen tool will permit remote monitoring of program execution progress with automatic protection against disconnection. It is a so-called terminal multiplexer, which allows us to create, shuffle, share, and suspend command line sessions within one window. It provides protection against disconnections and the flexibility
to retrieve command line sessions remotely.

You can download the screen tool from Http GNU Screen.
After downloading you can install it by,
tar -zxvf screen-4.0.2.tar.gz
cd screen-4.0.2
./configure && make
make install


Here 4.0.2 is the version number. Note that version 4.0.3 is available now.

After you download and install you can work with it.

The working steps are,
1. log in remote system where you do work usually via secure shell.
2. start screen. Just write screen on console.
3. run your long running operation here. Like take a dump of do any backup or restore operation or anything that need much times.
4. detach the screen session, using Ctrl+a or using Ctrl+d, and
5. log out.
The session continues working in the background, contained within the screen session. If we want to revisit the session to check its progress, then
1. log in that remote system via secure shell,
2. start screen -r, which in fact recalls the unattached session,
3. examine the saved buffer; scrolling around, copying and pasting as necessary,
4. detach the screen session, using Ctrl+a , Ctrl+d, and
5. log out.

Related Documents
How to change/configure IP Address on Linux/ Fedora /Ubuntu
Copy files between Unix and Windows with rcp
Different ways to take Screenshot on Linux
How to change the hostname in Linux
Memory Usage of Solaris Operating System

No comments:

Post a Comment