在Linux中,Screen是一个非常有用的工具,我们可以将程序在服务器端运行,然后使用Screen断开并保持程序的正常运行。
但是Screen有一个问题,就是每个连接的名称是 pid.tty.host
的格式,看上去不是很清楚,如下所示:
(base) root@instance-h9yr0vu1:~# (base) root@instance-h9yr0vu1:~# screen -r
There are several suitable screens on:
2053.pts-0.instance-h9yr0vu1 (02/09/2020 05:22:34 PM) (Detached)
1780.pts-0.instance-h9yr0vu1 (02/09/2020 04:41:13 PM) (Detached)
31580.pts-0.instance-h9yr0vu1 (02/09/2020 10:23:31 AM) (Attached)
Type "screen [-d] -r [pid.]tty.host" to resume one of them.
为了解决这个问题,我们可以使用命令 screen -S hostname
来启动一个新的连接。举例来说,我们新建立一个名为 mycon1
的连接,使用 screen -S mycon1
建立连接后,使用 Ctrl+a,d
(先按 ctrl+a
再按 d
) 断开后,可以看到 2301.mycon1
,这样在区分时就清楚多了。
(base) root@instance-h9yr0vu1:~# screen -r
There are several suitable screens on:
2301.mycon1 (02/09/2020 05:46:09 PM) (Detached)
2053.pts-0.instance-h9yr0vu1 (02/09/2020 05:22:34 PM) (Detached)
1780.pts-0.instance-h9yr0vu1 (02/09/2020 04:41:13 PM) (Detached)
31580.pts-0.instance-h9yr0vu1 (02/09/2020 10:23:31 AM) (Attached)
Type "screen [-d] -r [pid.]tty.host" to resume one of them.
另附几个不错的Screen指南:
[1] Linux Screen Tutorial With Examples,https://www.poftut.com/linux-screen-tutorial-examples/
[2] How To Install and Use Linux Screen, With Commands,https://phoenixnap.com/kb/how-to-use-linux-screen-with-commands
[3] Linux-screen 常用命令,https://www.iteye.com/blog/justdo2008-1888772
[4] How To Use Linux Screen,https://linuxize.com/post/how-to-use-linux-screen/