码迷,mamicode.com
首页 > 其他好文 > 详细

screen命令简介

时间:2016-03-19 06:37:50      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:screen

一、screen常用功能

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

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

   (3)多窗口


二、screen有什么用处?

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

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

 

三、screen基础命令

  [root@openvpn ~]# screen -ls  列出哪些程序在运行screen

  [root@openvpn ~]# screen -S apache 启动screen,给它加一个名字

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

四、安装screen

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

    screen-4.0.3-18.el6.x86_64

(2)[root@openvpn ~]# yum -y install screen  安装screen


(3)创建一个会话:

  [root@openvpn ~]# screen -S apache


(4)查看创建的会话:

[root@openvpn ~]# screen -ls

There is a screen on:

5410.apache (Attached)

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

[root@openvpn ~]# 

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

   [root@openvpn ~]# 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)恢复会话

[root@openvpn ~]# screen -ls  查看会话,名字是apache

There is a screen on:

5410.apache (Detached)

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


[root@openvpn ~]# 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)[root@openvpn ~]# screen -x apache  -x参数可以进入未断开的会话


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

screen命令简介

标签:screen

原文地址:http://cqtangbo.blog.51cto.com/2978612/1752673

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!