安装

yum install -y screen
[root@instance-- ~]# screen --help
Use: screen [-opts] [cmd [args]]
or: screen -r [host.tty] Options:
- Resolve hostnames only to IPv4 addresses.
- 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- 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@instance-- ~]# screen -R `date +%Y%m%d%H`

查看后台任务

[root@instance-- ~]# screen -ls
There is a screen on:
.20200326 (Detached)
Socket in /var/run/screen/S-root.

恢复一个后台任务

[root@instance-- ~]# screen -r 20200326

报错:

Cannot open your terminal '/dev/pts/1' - please check.

执行: script /dev/null

参数说明

-A  将所有的视窗都调整为目前终端机的大小。
-d <作业名称>  将指定的screen作业离线。
-h <行数>  指定视窗的缓冲区行数。
-m  即使目前已在作业中的screen作业,仍强制建立新的screen作业。
-r <作业名称>  恢复离线的screen作业。
-R  先试图恢复离线的作业。若找不到离线的作业,即建立新的screen作业。
-s  指定建立新视窗时,所要执行的shell。
-S <作业名称>  指定screen作业的名称。
-v  显示版本信息。
-x  恢复之前离线的screen作业。
-ls或--list  显示目前所有的screen作业。
-wipe  检查目前所有的screen作业,并删除已经无法使用的screen作业。

常用screen参数

screen -S yourname -> 新建一个叫yourname的session
screen -ls -> 列出当前所有的session
screen -r yourname -> 回到yourname这个session
screen -d yourname -> 远程detach某个session
screen -d -r yourname -> 结束当前session并回到yourname这个session

在每个screen session 下,所有命令都以 ctrl+a(C-a) 开始。

C-a ? -> 显示所有键绑定信息
C-a c -> 创建一个新的运行shell的窗口并切换到该窗口
C-a n -> Next,切换到下一个 window
C-a p -> Previous,切换到前一个 window
C-a .. -> 切换到第 .. 个 window
Ctrl+a [Space] -> 由视窗0循序切换到视窗9
C-a C-a -> 在两个最近使用的 window 间切换
C-a x -> 锁住当前的 window,需用用户密码解锁
C-a d -> detach,暂时离开当前session,将目前的 screen session (可能含有多个 windows) 丢到后台执行,并会回到还没进 screen 时的状态,此时在 screen session 里,每个 window 内运行的 process (无论是前台/后台)都在继续执行,即使 logout 也不影响。
C-a z -> 把当前session放到后台执行,用 shell 的 fg 命令则可回去。
C-a w -> 显示所有窗口列表
C-a t -> Time,显示当前时间,和系统的 load
C-a k -> kill window,强行关闭当前的 window
C-a [ -> 进入 copy mode,在 copy mode 下可以回滚、搜索、复制就像用使用 vi 一样
C-b Backward,PageUp
C-f Forward,PageDown
H(大写) High,将光标移至左上角
L Low,将光标移至左下角
移到行首
$ 行末
w forward one word,以字为单位往前移
b backward one word,以字为单位往后移
Space 第一次按为标记区起点,第二次按为终点
Esc 结束 copy mode
C-a ] -> Paste,把刚刚在 copy mode 选定的内容贴上

screen的安装使用的更多相关文章

  1. Screen命令安装使用教程

    在安装lnmp之前,我们一般先运行一下Screen程序,因为screen好像一个容器一样,把lnmp的安装过程保护了起来.以CentOS中安装lnmp为例,程序下载.编译都需要比较长的时间,如果中途遇 ...

  2. screen 命令安装使用

    初次接触Linux的朋友总会有个感觉:Windows平台想同时运行多个操作,执行多个程序或命令只需要打开程序即可:但在Linux中,命令行就一个,要想同时执行多个命令如何操作? 其实,只需要一个简简单 ...

  3. 安装lnmp前请先运行screen

    当通过putty或者SecureCRT安装lnmp时, 网络突然掉线或者不小心putty被关掉等等原因, 造成lnmp安装过程被中断怎么办? 其实防止这种现象很简单, 只要在安装lnmp前执行scre ...

  4. Ubuntu上安装Minecraft服务器

    Minecraft由于其独特的魅力吸引了很多玩家.不过游戏的乐趣只有在和朋友一起玩的时候才最有意思,所以很早以前我就想建设自己的服务器.但由于专业知识欠缺,没有实现. 最近接触了Linux服务器,所以 ...

  5. linux 命令(1)screen

    一.screen的安装和用法 Screen是一个可以在多个进程之间多路复用一个物理终端的窗口管理器,这意味着你能够使用一个单一的终端窗口运行多终端的应用. Screen中有会话的概念,用户可以在一个s ...

  6. linux之screen命令

    linux平台下想同时运行多个操作,执行多个程序或命令:命令行就一个,要想同时执行多个命令如何操作? 一个screen命令即可: Centos操作系统默认没有安装screen: 安装方法: Cento ...

  7. centos7安装laravel

    一. 安装前准备1. 安装screenyum install screen 2. 安装wgetyum install wget 3. 更新yumyum update 4. 安装额外资源库yum ins ...

  8. screen 命令基本操作教程

    sreen 命令提供的基本功能与 tmux 较为相似( 关于 tmux 基本操作可参见笔者的博文 终端复用工具 tmux 基本操作教程 ).screen 命令以会话( session )为基础为用户提 ...

  9. centos linux系统日常管理3 服务管理ntsysv,chkconfig,系统日志rsyslog,last ,lastb ,exec,xargs,dmesg,screen,nohup,curl,ping ,telnet,traceroute ,dig ,nc,nmap,host,nethogs 第十六节课

    centos linux系统日常管理3  服务管理ntsysv,chkconfig,系统日志rsyslog,last ,lastb ,exec,xargs,dmesg,screen,nohup,cur ...

随机推荐

  1. python新手必躺的5大坑

    python新手必躺的5大坑 对于Python新手来说,写代码很少考虑代码的效率和简洁性,因此容易造成代码冗长.执行慢,这些都是需要改进的地方.本文是想通过几个案列给新手一点启发,怎样写python代 ...

  2. Codeforces 1238G. Adilbek and the Watering System

    传送门 最关键的想法就是每个位置一定用的是当前能用的最便宜的水,因为到后面可能有更便宜的 然后其他还没用上的水我们也留着,假装此时已经买了,但是如果发现后面有更优的再反悔也不迟 每相邻两个朋友之间我们 ...

  3. API接口利用ActionFilterAttribute实现接口耗时检测

    1.主要代码 using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; ...

  4. C++ STL用法总结(持续更新)

    Vector 动态数组 https://www.cnblogs.com/zhonghuasong/p/5975979.html lower_bound&&upper_bound htt ...

  5. redis集群+JedisCluster+lua脚本实现分布式锁(转)

    https://blog.csdn.net/qq_20597727/article/details/85235602 在这片文章中,使用Jedis clien进行lua脚本的相关操作,同时也使用一部分 ...

  6. javascript&jquery方法比对

    参考链接:https://juejin.im/post/5d2705d8e51d4577407b1dda 参考评论链接http://youmightnotneedjquery.com/ javascr ...

  7. js页面加载时候的调用函数的方法

    方法一:jquery 中:$(function(){}) 括号内写你的内容 方法二:html <body onload=''> <script type="text/jav ...

  8. iptables防火墙操作-查看、配置、重启、关闭

    查看iptables端口配置 iptables -L -n --line-number iptables端口配置(不开通3389无法远程连接,不开通icmp无法ping) iptables -A IN ...

  9. python图像处理-生成随机验证码

    前面说了PIL库,还说了图片的缩放.旋转和翻转.现在说下网站上常用的随机验证码的生成.参考网站:https://www.liaoxuefeng.com/wiki/1016959663602400/10 ...

  10. Caused by: java.lang.UnsatisfiedLinkError: Couldn't load 。。。。

    最近需要做个有地图搜索功能的模块,用到百度地图SDK,但是从官网上下载SDK后导入工程,修改apiKey后,还是无法运行,总是抱这个错误:Caused by: java.lang.Unsatisfie ...