Minggu, 02 September 2018

How to install and use screen to avoid our linux command stop due network issue

  Tidak ada komentar
install screen by typing sudo yum install screen as shown bellow 
[maswachid@monitor ~]$
[maswachid@monitor ~]$ sudo yum install screen
[sudo] password for maswachid:
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
base                                                      | 3.7 kB     00:00
epel                                                      | 3.2 kB     00:00
extras                                                   | 3.4 kB     00:00
updates                                                | 3.4 kB     00:00
Resolving Dependencies
--> Running transaction check
---> Package screen.x86_64 0:4.0.3-19.el6 will be installed
wait until installation proccess finish as shown bellow
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : screen-4.0.3-19.el6.x86_64                                   1/1
  Verifying  : screen-4.0.3-19.el6.x86_64                                  1/1

Installed:
  screen.x86_64 0:4.0.3-19.el6

Complete!
[maswachid@hubmonitor ~]$

to start using screen, just typing we typing screen at terminal

SYNOPSIS
       screen [ -options ] [ cmd [ args ] ]
       screen -r [[pid.]tty[.host]]

       screen -r sessionowner/[[pid.]tty[.host]]
[root@monitor-cloud ~]#
[root@monitor-cloud ~]# screen
After we typing screen, we will redirect to empty terminal
[root@monitoring-cloud ~]#
[root@monitoring-cloud ~]# 

we can type any command as usual, on figure bellow we will perform rsync command
[root@monitoring-cloud ~]#
[root@monitoring-cloud ~]# rsync --bwlimit=100 -aclzhe ssh --progress  [email protected]:/home/omd_cmk/automatis ~/omd_cmk/
[email protected]'s password:
receiving incremental file list
created directory /root/omd_cmk
automatis/
automatis/Check_MK-monitor.wachid.web.id-mon-bkp_auto-complete/
automatis/Check_MK-monitor.wachid.web.id-mon-bkp_auto-complete/mkbackup.info
            734 100%  716.80kB/s    0:00:00 (xfr#1, to-chk=2/6)
automatis/Check_MK-monitor.wachid.web.id-mon-bkp_auto-complete/site-mon.tar.gz
          1.49M   0%   98.77kB/s    3:03:46

We can leave it running in background by detach it by pushing ctrl + a + d  or we can leave it open like normal terminal
[detached from 7211.pts-0.monitor-cloud]
[root@monitor-cloud ~]#
[root@monitor-cloud ~]#
We can resume our session on screen (attach) by typing screen -r [pid] we need choose the session if there are more than one session of screen else we will automatically open the screen session
[root@monitor-cloud ~]#
[root@monitor-cloud ~]# screen -r
There are several suitable screens on:
        7211.pts-0.monitoring-cloud     (Detached)
        67748.pts-0.localhost   (Detached)
Type "screen [-d] -r [pid.]tty.host" to resume one of them.
[root@monitor-cloud ~]#
[root@monitor-cloud ~]#
we will found our terminal as last seen
[root@monitor-cloud ~]#
[root@monitor-cloud ~]# rsync --bwlimit=100 -aclzhe ssh --progress  [email protected]:/home/omd_cmk/automatis ~/omd_cmk/
[email protected]'s password:
receiving incremental file list
created directory /root/omd_cmk
automatis/
automatis/Check_MK-monitor.wachid.web.id-mon-bkp_auto-complete/
automatis/Check_MK-monitor.wachid.web.id-mon-bkp_auto-complete/mkbackup.info
            734 100%  716.80kB/s    0:00:00 (xfr#1, to-chk=2/6)
automatis/Check_MK-monitor.wachid.web.id-mon-bkp_auto-complete/site-mon.tar.gz
         94.08M   8%  102.20kB/s    2:42:31
Here are some option that we can use on screen app
[root@monitor-cloud ~]#
[root@monitor-cloud ~]# screen --help
Use: screen [-opts] [cmd [args]]
 or: screen -r [host.tty]

Options:
-4            Resolve hostnames only to IPv4 addresses.
-6            Resolve hostnames only to IPv6 addresses.
-a            Force all capabilities into each window's termcap.
-A -[r|R]     Adapt all windows to the new display width & height.
-c file       Read configuration file instead of '.screenrc'.
-d (-r)       Detach the elsewhere running screen (and reattach here).
-dmS name     Start as daemon: Screen session in detached mode.
-D (-r)       Detach and logout remote (and reattach here).
-D -RR        Do whatever is needed to get a screen session.
-e xy         Change command characters.
-f            Flow control on, -fn = off, -fa = auto.
-h lines      Set the size of the scrollback history buffer.
-i            Interrupt output sooner when flow control is on.
-l            Login mode on (update /var/run/utmp), -ln = off.
-ls [match]   or
-list         Do nothing, just list our SockDir [on possible matches].
-L            Turn on output logging.
-m            ignore $STY variable, do create a new screen session.
-O            Choose optimal output rather than exact vt100 emulation.
-p window     Preselect the named window if it exists.
-q            Quiet startup. Exits with non-zero return code if unsuccessful.
-Q            Commands will send the response to the stdout of the querying process.
-r [session]  Reattach to a detached screen process.
-R            Reattach if possible, otherwise start a new session.
-s shell      Shell to execute rather than $SHELL.
-S sockname   Name this session <pid>.sockname instead of <pid>.<tty>.<host>.
-t title      Set title. (window's name).
-T term       Use term as $TERM for windows, rather than "screen".
-U            Tell screen to use UTF-8 encoding.
-v            Print "Screen version 4.01.00devel (GNU) 2-May-06".
-wipe [match] Do nothing, just clean up SockDir [on possible matches].
-x            Attach to a not detached screen. (Multi display mode).
-X            Execute <cmd> as a screen command in the specified session.
[root@monitoring-cloud ~]#

rsync  --bwlimit=800 -aulzhRe ssh --progress  /home/omd_cmk/manual/./Check_MK-wachid.web.id-monitoring-bkp_manual-complete [email protected]:/root/omd_cmk/manual/


Tidak ada komentar :

Posting Komentar