screen,虛擬的一個屏幕,也能夠理解爲一個虛擬的終端session
需求,執行一個腳本,須要一天一晚上,並且腳本會輸出一些東西出來,這就意味着這個腳本不能中途斷開,保證腳本不中斷,有兩種方法:工具
安裝screen包——>yum install -y screen日誌
[root@hf-01 ~]# screen 在虛擬終端下執行了vmstat 1,按 ctrl+a鍵 同時按,隨後再按 d鍵 ,就把screen丟到後臺了 [detached from 2841.pts-0.hf-01] [root@hf-01 ~]# screen -ls //列出當前全部的session There is a screen on: 2841.pts-0.hf-01 (Detached) 1 Socket in /var/run/screen/S-root. [root@hf-01 ~]# screen -r 2841 //從新回到虛擬終端——>若不須要screen了,直接殺死,按 exit 便可 [screen is terminating] [root@hf-01 ~]# screen -ls //再次查看,會發現沒有screen No Sockets found in /var/run/screen/S-root. [root@hf-01 ~]#
[root@hf-01 ~]# screen [detached from 2880.pts-0.hf-01] [root@hf-01 ~]# screen [detached from 2903.pts-0.hf-01] [root@hf-01 ~]# screen [detached from 2926.pts-0.hf-01] [root@hf-01 ~]# screen -ls There are screens on: 2926.pts-0.hf-01 (Detached) 2903.pts-0.hf-01 (Detached) 2880.pts-0.hf-01 (Detached) 3 Sockets in /var/run/screen/S-root. [root@hf-01 ~]#