screen命令相关

来源:互联网 发布:福建广电网络中考查分 编辑:程序博客网 时间:2024/04/29 15:13

screen 作用
Screen可以使用一个终端窗口处理多个服务器进程的操作,并且不会使操作中断。例如我们需要运行一个case很久,但是又要关闭这个终端窗口或者关闭终端的机器;那么用screen可以解决这个问题。我们用终端登录到server上,然后启动一个screen终端窗口,运行case,退出screen窗口,退出终端。下次我们再次进入screen窗口时,还可以看到上次进入的时启动的case的运行状态,就像是窗口一直没有关闭一样。

经常用的 screen 命令


一般情况下,都需要我们用Screen命令下创建多个段,每个段中再创建多个窗口。

screen -S session名:创建一个新的段
screen -r session名:重新登录一个段

screen -ls :查看所有的段

进入段后,使用Ctrl+A  * 对段进行操作:

Ctrl+A  d 退出当前的段

Ctrl+A  c -> Create,开启新的 window
Ctrl+A  n -> Next,切换到下个 window
Ctrl+A  p -> Previous,前一个 window
Ctrl+A  Ctrl+A  -> Other,在两个 window 间切换
Ctrl+A  w -> Windows,列出已开启的 windows 有那些
Ctrl+A  0...9 -> 切换到第 0 ...9个 window
Ctrl+A  a -> 发出 C-a,在 emacs, ve, bash, tcsh 下可移到行首
Ctrl+A  t -> Time,显示当前时间,和系统的 load
Ctrl+A  K(大写) -> kill window,强行关闭当前的 window
Ctrl+A  [ -> 进入 copy mode,在 copy mode 下可以回滚、搜索、
复制就像用使用 vi 一样
Ctrl-b Backward,PageUp
Ctrl-f Forward,PageDown
H(大写) High,将光标移至左上角
L Low,将光标移至左下角
0 移到行首
$ 行末
w forward one word,以字为单位往前移
b backward one word,以字为单位往后移
Space 第一次按为标记区起点,第二次按为终点
Esc 结束 copy mode
C-a ] -> Paste,把刚刚在 copy mode 选定的内容贴上
C-a ? -> Help,显示简单说明
C-a d -> detach,将目前的 screen session (可能含有多个 windows)

screen 各个参数

[sherry@docomo6 ~]$ screen -help
Use: screen [-opts] [cmd [args]]
 or: screen -r [host.tty]

Options:
-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.
-list         or -ls. Do nothing, just list our SockDir.
-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.
-r            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.00.02 (FAU) 5-Dec-03".
-wipe         Do nothing, just clean up SockDir.
-x            Attach to a not detached screen. (Multi display mode).
-X            Execute <cmd> as a screen command in the specified session.

原创粉丝点击