1. 前言
实际开发中用到的云服务器,如果项目使用的是python,需要利用项目运行一些时间较长的项目程序脚本的话,由于我们通过ssh连接远端服务器,网络异常或者占用服务器较久可能会中断ssh的连接,此时当我们再进入服务器的时候,我们运行脚本的程序窗口由于我们的连接中断,之前的会话就丢失无法恢复了。
如果我们想要实现与服务器断开后重连依然可以找到脚本运行的程序窗口,则可以用screen命令来实现新建窗口与会话恢复。
2. screen是什么?
在linux服务器中,使用man screen
命令可以看到关于screen的使用手册。
man screen
对screen的介绍如下:
Screen is a full-screen window manager that multiplexes a physical terminal between several
processes (typically interactive shells). Each virtual terminal provides the functions of a
DEC VT100 terminal and, in addition, several control functions from the ISO 6429 (ECMA 48,
ANSI X3.64) and ISO 2022 standards (e.g. insert/delete line and support for multiple character
sets). There is a scrollback history buffer for each virtual terminal and a copy-and-paste
mechanism that allows moving text regions between windows.Screen是一个全屏窗口管理器,它在多个物理终端之间多路传输物理终端进程(通常是交互式shell)。每个虚拟终端提供的功能DEC VT100终端以及来自ISO 6429的几个控制功能(ECMA 48,ANSI X3.64)和ISO 2022标准(例如插入/删除行和支持多个字符套)。每个虚拟终端都有一个滚动历史缓冲区和一个复制粘贴允许在窗口之间移动文本区域的机制。
When screen is called, it cre