How to install #
//Yum
[root@nso ~]# yum -y install screen
//rpm
[root@nso ~]#wget http://mirror-hk.koddos.net/centos/7.8.2003/os/x86_64/
Packages/screen-4.1.0-0.25.20120314git3c2946.el7.x86_64.rpm
[root@nso ~]#rpm -ivh screen-4.1.0-0.25.20120314git3c2946.el7.x86_64.rpm
Some Tips #
Created a session, -S means special a name for that session.
[root@xuxing ~]# screen
[root@xuxing ~]# screen -S test
Recover your session.
[root@xuxing ~]# screen -ls
There are screens on:
15741.test (Detached)
5971.pts-2.xuxing (Detached)
4485.pts-2.xuxing (Detached)
4409.pts-0.xuxing (Detached)
25997.9922a (Detached)
5 Sockets in /var/run/screen/S-root.
[root@xuxing ~]# screen -r test // recover test session
[detached from 15741.test]
Detached session/Kill session
//使用组合键 C-a D detach session, 即将session 放在后台
[root@xuxing ~]# screen -ls
There are screens on:
15741.test (Detached)
5971.pts-2.xuxing (Detached)
4485.pts-2.xuxing (Detached)
4409.pts-0.xuxing (Detached)
25997.9922a (Detached)
5 Sockets in /var/run/screen/S-root.
[root@xuxing ~]# kill -9 15741
[root@xuxing ~]# screen -ls
There are screens on:
15741.test (Dead ???)
5971.pts-2.xuxing (Detached)
4485.pts-2.xuxing (Detached)
4409.pts-0.xuxing (Detached)
25997.9922a (Detached)
Remove dead screens with 'screen -wipe'.
5 Sockets in /var/run/screen/S-root.
[root@xuxing ~]# screen -wipe
There are screens on:
15741.test (Removed)
5971.pts-2.xuxing (Removed)
4485.pts-2.xuxing (Detached)
4409.pts-0.xuxing (Detached)
25997.9922a (Detached)
2 sockets wiped out.
3 Sockets in /var/run/screen/S-root.
[root@xuxing ~]# screen -ls
There are screens on:
4485.pts-2.xuxing (Detached)
4409.pts-0.xuxing (Detached)
25997.9922a (Detached)
3 Sockets in /var/run/screen/S-root.
[root@xuxing ~]#
About screen session log, we have 3 way to enable it:
// Way 1: add -L to enable session log
// it will auto generate a log file at user home folder $HOME with name session title name
[root@xuxing ~]# screen -S -L test
// Way 2: create a normal session , type Ctrl+a, H to enable session log
// it will be stored at user home folder too
[root@xuxing ~]# screen -S test
> Ctrl+a, H
// Way 3: customize session log save folder by modify config file
[root@server1 ~]# grep logfile /etc/screenrc
logfile /var/log/screen/screenlog_%S_%t_%Y_%m_%d_%c.%n.log
[root@xuxing ~]# screen -S -L test