1、screen:screen manager with VT100/ANSI terminal emulation
1)簡介:一個可以在多個進程(通常是交互式shell)之間復用一個物理終端的全屏幕窗口管理器。
使用screen時,程序“運行”在screen會話中(作為會話shell的子進程),此時detach會話不會中斷會話中的程序。當再次attach該會話時,又可以回到detach之前的狀態。
2)常用選項:-S name:為會話指定名字;-r session:恢復detached的會話;-ls [match]:列舉所有/匹配的會話;-d -m:以detached模式創建會話(常用於系統啟動腳本);-d [match]:detach一個正在使用的會話。在會話控制終端鍵入Ctrl-a d可detach該會話;-wipe [match]:和-ls一樣,但會移除已銷毀的會話,而不是標記為dead。
3)例子:
(1)創建新會話:
screen -S han vim test # 若要終止會話:退出vim->鍵入Ctrl-d screen vim test # 直接指定在screen會話中運行的程序。這種情況下,退出vim即終止會話
(2)在(1)中會話未終止時,鍵入Ctrl-a d,將detach該會話。
(3)使用screen -ls查詢所有會話:
[root@localhost ~]# screen -ls There is a screen on: 3985.han (Detached) 1 Socket in /var/run/screen/S-root.
可見會話當前狀態是Detached的。
(4)恢復會話:
screen -r 3985 # 回到detach前的狀態
不斷學習中。。。