screen4.9.0 离线安装(服务器ssh断连后,可以继续保持程序运行,以及查看打印信息)

Screen被称之为一个全屏窗口管理器,可以轻松在一个物理终端上获得多个虚拟终端的效果。你能够使用一个单一的终端窗口运行多终端的应用。Screen中有会话的概念,用户可以在一个screen会话中创建多个screen窗口,在每一个screen窗口中就像操作一个真实的telnet/SSH连接窗口那样。即使SSH远程连接被中断,你可以通过命令恢复该会话。

1 下载

screen 下载网址 http://ftp.gnu.org/gnu/screen/
ncurses 下载网址 http://ftp.gnu.org/gnu/ncurses/

查看网上教程,安装screen可能会出错,需要安装ncurses软件,因此我直接先安装ncurses,后安装screen.

2 解压

tar -zxvf ncurse-6.3.tar.gz
tar -zxvf screen-4.9.0.tar.gz
在这里插入图片描述

3 安装

3.1 ncurse

进入目录 cd ncurse-6.3
创建build文件夹 mkdir build && cd build
配置环境 ../configure
编译 sudo make
安装 sudo make install
如果安装报错权限不够,将build下文件权限都改为777 chmod 777 ./* 再次安装

3.2 screen

同上,直接跳到配置环境这一步,发现没有configure文件,怎么办?
查找文件中有没有README 或者INSTALL 文件,这些文件是用来提供帮助文档使用,包括软件使用命令文档、安装文档
使用cat INSTALL 查看安装教程
在这里插入图片描述
可以发现,运行autogen.sh 可以生成configure文件,之后的安装过程与necurses一样。

安装完成后,查看
在这里插入图片描述

基本用法

screen手册:http://www.gnu.org/software/screen/manual/screen.html

@dell-PowerEdge-R940xa:~$ 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.
-ls [match]   or
-list         Do nothing, just list our SockDir [on possible matches]. 查看所有会话
-L            Turn on output logging.
-Logfile file Set logfile name.
-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.09.00 (GNU) 30-Jan-22".
-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.

创建终端
  1. screen 默认命令,默认命名复杂

  2. screen -S session_name 创建一个自己命名的会话,不会检测同名会话,也就是可能创建同名会话

  3. screen -R session_name 创建一个自己命名的会话,检查有没有同名会话已经创建,若有,则进入该回话

  4. screen -ls 查看所有会话

  5. screen -r 恢复会话

  6. exit 清除会话(进入会话后)

  • 4
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值