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 ~]#