screen命令简介
一、screen常用功能
? ?(1)會話恢復--最常用--使用運維工具網絡斷開后也可以恢復會話
? ?(2)會話共享--我在做操作,其他人也可以看見
? ?(3)多窗口
二、screen有什么用處?
? ? 假如我們正在運行一個程序,可能要跑幾個小時,但是中途斷網了,
在連接上去看不到程序的運行狀態,這時就可以用screen來創建會話了。
?
三、screen基礎命令
? [root@open*** ~]# screen -ls ?列出哪些程序在運行screen
? [root@open*** ~]# screen -S apache 啟動screen,給它加一個名字
? [root@open*** ~]# screen -x apache ?-x參數可以進入未斷開的會話
四、安裝screen
(1)[root@open*** ~]# rpm -qa | grep screen ?查詢本機是否安裝screen
? ? screen-4.0.3-18.el6.x86_64
(2)[root@open*** ~]# yum -y install screen ?安裝screen
(3)創建一個會話:
? [root@open*** ~]# screen -S apache
(4)查看創建的會話:
[root@open*** ~]# screen -ls
There is a screen on:
5410.apache (Attached)
1 Socket in /var/run/screen/S-root.
[root@open*** ~]#?
(5)測試 ?執行一個ping任務,然后斷開
? ?[root@open*** ~]# 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@open*** ~]# screen -ls ?查看會話,名字是apache
There is a screen on:
5410.apache (Detached)
1 Socket in /var/run/screen/S-root.
[root@open*** ~]# 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@open*** ~]# screen -x apache ?-x參數可以進入未斷開的會話
轉載于:https://blog.51cto.com/cqtangbo/1752673
總結
以上是生活随笔為你收集整理的screen命令简介的全部內容,希望文章能夠幫你解決所遇到的問題。