shallow丿ove
screen工具
- 为了不让一个任务意外终端
- nohup command &
- screen是一个虚拟终端
- yum install -y screen
- screen直接回车就进入了虚拟终端
- ctral a组合键再按d退出虚拟终端,但不是结束
- screen -ls查看虚拟终端列表
- screen -r id 进入指定的终端
- screen -S aming
- screen -r aming
执行脚本,时间长,脚本会输出,不能中断
[root@localhost ~]# yum install -y screen
Loaded plugins: fastestmirror
base | 3.6 kB 00:00:00
epel/x86_64/metalink | 7.9 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/2): extras/7/x86_64/primary_db | 130 kB 00:00:00
(2/2): updates/7/x86_64/primary_db | 4.5 MB 00:00:07
Loading mirror speeds from cached hostfile
* epel: mirrors.sohu.com
Resolving Dependencies
--> Running transaction check
---> Package screen.x86_64 0:4.1.0-0.23.20120314git3c2946.el7_2 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================================
Package Arch Version Repository Size
===================================================================================================
Installing:
screen x86_64 4.1.0-0.23.20120314git3c2946.el7_2 base 552 k
Transaction Summary
===================================================================================================
Install 1 Package
Total download size: 552 k
Installed size: 914 k
Downloading packages:
screen-4.1.0-0.23.20120314git3c2946.el7_2.x86_64.rpm | 552 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : screen-4.1.0-0.23.20120314git3c2946.el7_2.x86_64 1/1
Verifying : screen-4.1.0-0.23.20120314git3c2946.el7_2.x86_64 1/1
Installed:
screen.x86_64 0:4.1.0-0.23.20120314git3c2946.el7_2
Complete!
进入虚拟终端
[root@localhost ~]# screen
[root@localhost ~]#
[root@localhost ~]# w
09:49:41 up 5:26, 2 users, load average: 0.08, 0.06, 0.06
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
root tty1 04:24 1:43m 0.07s 0.07s -bash
root pts/0 09:48 5.00s 0.01s 0.00s w
使用w看不出任何变化
[root@localhost ~]# vmstat 1
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
1 0 0 1513996 692 197840 0 0 5 1 12 15 0 0 100 0 0
0 0 0 1513956 692 197872 0 0 0 0 31 35 0 0 100 0 0
0 0 0 1513956 692 197872 0 0 0 0 19 21 0 0 100 0 0
0 0 0 1513956 692 197872 0 0 0 9 36 53 0 0 100 0 0
0 0 0 1513956 692 197872 0 0 0 0 40 61 0 0 100 0 0
0 0 0 1513956 692 197872 0 0 0 0 41 65 0 0 100 0 0
0 0 0 1513956 692 197872 0 0 0 0 41 63 0 0 100 0 0
.
.
.
(ctrl+A)+D
[root@localhost ~]# screen
[detached from 4497.pts-1.localhost]
screen -ls
[root@localhost ~]# screen -ls
There is a screen on:
4497.pts-1.localhost (Detached)
1 Socket in /var/run/screen/S-root.
返回screen -r 4497
[root@localhost ~]# screen -r 4497
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
1 0 0 1513996 692 197840 0 0 5 1 12 15 0 0 100 0 0
0 0 0 1513956 692 197872 0 0 0 0 31 35 0 0 100 0 0
0 0 0 1513956 692 197872 0 0 0 0 19 21 0 0 100 0 0
0 0 0 1513956 692 197872 0 0 0 9 36 53 0 0 100 0 0
0 0 0 1513956 692 197872 0 0 0 0 40 61 0 0 100 0 0
0 0 0 1513956 692 197872 0 0 0 0 41 65 0 0 100 0 0
0 0 0 1513956 692 197872 0 0 0 0 41 63 0 0 100 0 0
.
.
.
^C
[root@localhost ~]# exit
[root@localhost ~]# screen -ls
No Sockets found in /var/run/screen/S-root.
[root@localhost ~]# screen
[detached from 4558.pts-1.localhost]
[root@localhost ~]# screen
[detached from 4576.pts-1.localhost]
[root@localhost ~]# screen
[detached from 4594.pts-1.localhost]
[root@localhost ~]# screen -ls
There are screens on:
4594.pts-1.localhost (Detached)
4576.pts-1.localhost (Detached)
4558.pts-1.localhost (Detached)
3 Sockets in /var/run/screen/S-root.
screen -S "name"
[root@localhost ~]# screen -S "test_screen"
[detached from 4613.test_screen]
[root@localhost ~]# screen -ls
There are screens on:
4613.test_screen (Detached)
4594.pts-1.localhost (Detached)
4576.pts-1.localhost (Detached)
4558.pts-1.localhost (Detached)
4 Sockets in /var/run/screen/S-root.