screen

2023-06-07,

screen

yun install -y screen

screen  进入screen窗口

ctrl +a +d 退出screen窗口

screen ls 查看已经在后台运行的screen

在screen窗口中输入运行top或者vmst命令然后退出

ps aux | grep -E 'top|vmst'

查看刚才在screen中运行的top或者vmst服务

[root@hatch ~]# screen       #创建一个screen会话

[root@hatch ~]# screen -S test      #创建一个带名字的screen会话,并且attached模式

[root@hatch ~]# screen -dm test1    #并默认是detached模式,也就是建好之后不会连上去。

[root@hatch ~]# screen -d -r test2  #结束当前screen并回到test2这个screen

[root@hatch ~]# screen -ls           #查看所有会话
There are screens on:
        8504.test2      (Detached)
        8010..hatch     (Detached)
        8060.test1      (Detached)
        6275.test       (Attached)
        6199.pts-3.hatch        (Detached)
5 Sockets in /var/run/screen/S-root.

[root@hatch ~]# screen -r 8060(or test1)    #恢复到以前的离线screen进程

[root@hatch ~]# Ctrl+a+d                    #按Ctrl+a,然后再按d即可保留Screen
[detached]                                  #这时会显示出这个提示,说明已经保留好Screen了

[root@hatch ~]# exit                        #如果你工作完成的话,这样就表示成功退出了
[screen is terminating]

[root@hatch ~]# Ctrl+a+n      #下一个screen 会话
[root@hatch ~]# Ctrl+a+p      #上一个screen 会话
[root@hatch ~]# Ctrl+a+c      #创建新的screen 会话

《screen.doc》

下载本文的Word格式文档,以方便收藏与打印。