본문 바로가기

리눅스

screen 명령어

728x90

screen 명령어

Summary : A screen manager that supports multiple logins on one terminal

screen 설치

yum install -y screen

screen 세션 시작

  • 세션 생성

screen -S [session name]

screen -S sangchul
$ screen -S sangchul
[detached from 4008445.sangchul]
  • 세션 나기기
Ctrl + a, d
  • 세션 리스트 확인
screen -ls
$ screen -ls
There are screens on:
	4008445.sangchul	(Detached)
	4008392.sangchu	(Detached)
2 Sockets in /var/run/screen/S-root.
  • 세션 다시 연결

screen -r [session name]

screen -r sangchul

세션이 하나만 있을경우

screen -r
  • 세션 종료

screen -X -S [session name] quit

screen -ls
$ screen -ls
There are screens on:
	4008445.sangchul	(Detached)
	4008392.sangchu	(Detached)
2 Sockets in /var/run/screen/S-root.
screen -X -S sangchu quit
screen -ls
$ screen -ls
There is a screen on:
	4008445.sangchul	(Detached)
1 Socket in /var/run/screen/S-root.
728x90

screen 명령 사용법

$ 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.

 

스크린을 이용한 rsync 데이타 동기화 작업(rsync 백그라운드 실행)

$ screen -S Rsync

    >>> [user01@bvm01 ~]$ cd /app

    >>> [user01@bvm01 app]$ rsync -az -e ssh user01@111.111.111.111:/app/ .

    >>> user01@111.111.111.111's password:

    >>> Ctrl + a, d

[root@bvm01 ~]$ screen -S Rsync
    >>> [user01@bvm01 ~]$ cd /app
    >>> [user01@bvm01 app]$ rsync -az -e ssh user01@111.111.111.111:/app/ .
    >>> user01@111.111.111.111's password:
    >>> Ctrl + a, d

[detached from 324059.Rsync]
[root@bvm01 ~]$ screen -ls
There is a screen on:
    324059.Rsync (Detached)
1 Socket in /run/screen/S-root.
[root@bvm01 ~]$ screen -r
>>> [user01@bvm01 app]$ screen -X -S 324059..Rsync quit
[screen is terminating]
[root@bvm01 ~]$ screen -ls
No Sockets found in /run/screen/S-root.

 

참고URL

- 우분투에서 Screen 설치 및 사용하기: https://sangchul.kr/850

 

728x90

'리눅스' 카테고리의 다른 글

Apache(HTTP) 및 PHP 버전 정보 노출 막기  (0) 2022.01.28
[linux] rpcgen install for centos 8  (0) 2022.01.27
nmap 명령어  (0) 2022.01.24
nc 명령어  (0) 2022.01.24
curl 명령어로 웹사이트 로딩 속도를 테스트하는 방법  (0) 2022.01.21