screen命令简介

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了screen命令简介相关的知识,希望对你有一定的参考价值。

一、screen常用功能

   (1)会话恢复--最常用--使用运维工具网络断开后也可以恢复会话

   (2)会话共享--我在做操作,其他人也可以看见

   (3)多窗口


二、screen有什么用处?

    假如我们正在运行一个程序,可能要跑几个小时,但是中途断网了,

在连接上去看不到程序的运行状态,这时就可以用screen来创建会话了。

 

三、screen基础命令

  [[email protected] ~]# screen -ls  列出哪些程序在运行screen

  [[email protected] ~]# screen -S apache 启动screen,给它加一个名字

  [[email protected] ~]# screen -x apache  -x参数可以进入未断开的会话

四、安装screen

(1)[[email protected] ~]# rpm -qa | grep screen  查询本机是否安装screen

    screen-4.0.3-18.el6.x86_64

(2)[[email protected] ~]# yum -y install screen  安装screen


(3)创建一个会话:

  [[email protected] ~]# screen -S apache


(4)查看创建的会话:

[[email protected] ~]# screen -ls

There is a screen on:

5410.apache (Attached)

1 Socket in /var/run/screen/S-root.

[[email protected] ~]# 

(5)测试  执行一个ping任务,然后断开

   [[email protected] ~]# ping baidu.com

PING baidu.com (123.125.114.144) 56(84) bytes of data.

64 bytes from 123.125.114.144: icmp_seq=1 ttl=51 time=50.3 ms

64 bytes from 123.125.114.144: icmp_seq=2 ttl=51 time=50.1 ms

64 bytes from 123.125.114.144: icmp_seq=3 ttl=51 time=50.1 ms

64 bytes from 123.125.114.144: icmp_seq=4 ttl=51 time=50.1 ms

64 bytes from 123.125.114.144: icmp_seq=5 ttl=51 time=50.2 ms

64 bytes from 123.125.114.144: icmp_seq=6 ttl=51 time=50.2 ms


(6)恢复会话

[[email protected] ~]# screen -ls  查看会话,名字是apache

There is a screen on:

5410.apache (Detached)

1 Socket in /var/run/screen/S-root.


[[email protected] ~]# screen -r apache 用-r参数恢复会话

64 bytes from 123.125.114.144: icmp_seq=77 ttl=51 time=50.1 ms

64 bytes from 123.125.114.144: icmp_seq=78 ttl=51 time=50.4 ms

64 bytes from 123.125.114.144: icmp_seq=79 ttl=51 time=50.4 ms

64 bytes from 123.125.114.144: icmp_seq=80 ttl=51 time=51.3 ms

64 bytes from 123.125.114.144: icmp_seq=81 ttl=51 time=53.4 ms

64 bytes from 123.125.114.144: icmp_seq=82 ttl=51 time=49.7 ms

64 bytes from 123.125.114.144: icmp_seq=84 ttl=51 time=50.2 ms

64 bytes from 123.125.114.144: icmp_seq=85 ttl=51 time=50.2 ms

64 bytes from 123.125.114.144: icmp_seq=86 ttl=51 time=50.2 ms

64 bytes from 123.125.114.144: icmp_seq=87 ttl=51 time=51.6 ms

64 bytes from 123.125.114.144: icmp_seq=88 ttl=51 time=52.2 ms


(7)[[email protected] ~]# screen -x apache  -x参数可以进入未断开的会话


本文出自 “山猫” 博客,请务必保留此出处http://cqtangbo.blog.51cto.com/2978612/1752673

以上是关于screen命令简介的主要内容,如果未能解决你的问题,请参考以下文章

linux screen 命令详解

linux screen 命令详解

Linux中的screen命令使用

Linux命令screen用法小计

linux screen 命令详解

linux screen 命令详解