根据主页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 the DEC VT100 terminal and, in addition, several control functions from the ANSI X3.64 (ISO 6429) 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 the user to move text regions between windows. When screen is called, it creates a single window with a shell in it (or the specified command) and then gets out of your way so that you can use the program as you normally would. Then, at any time, you can create new (full-screen) windows with other programs in them (including more shells), kill the current window, view a list of the active windows, turn output logging on and off, copy text between windows, view the scrollback history, switch between windows, etc. All windows run their programs completely independent of each other. Programs continue to run when their window is currently not visible and even when the whole screen session is detached from the users terminal.”

开个终端远程连接服务器提交计算任务时,只能挂着机子,终端无法关闭,一关计算任务也就断了。使用screen就可以了。在终端里敲screen就进入screen了,跟原来的终端是没两样的。但是神奇的是,当你敲Control-ad的时候,这个session就detach了,关机重启都没问题,再到终端上键入screen -r就可以重新attach原先那个session,原先提交的任务没有断开,程序依然在跑。这样就不用整天挂着机子等服务器端的计算了。

更为方便的是,比如在实验室里挂着机子使用screen连到服务器上,没有detach,然后到了宿舍,想看程序跑得怎么样。可以远程登录上去,使用screen -dr把原先的session detach,然后再重新attach,这样到那都可以进行控制。不会受到限制。