刚刚才注意,默认情况下rhel6 是不安装screen命令的:[[email protected] yum.repos.d]# yum install screenLoaded plugins: product-id, refresh-packagekit, security, subscription-managerUpdating certificate-based repositories.Unable to read consumer identityrhel-source | 4.0 kB 00:00 ... rhel-source-beta | 4.0 kB 00:00 ... Setting up Install ProcessResolving Dependencies--> Running transaction check---> Package screen.x86_64 0:4.0.3-16.el6 will be installed--> Finished Dependency ResolutionDependencies Resolved============================================================================================================================================================ Package Arch Version Repository Size============================================================================================================================================================Installing: screen x86_64 4.0.3-16.el6 rhel-source 494 kTransaction Summary============================================================================================================================================================Install 1 Package(s)Total download size: 494 kInstalled size: 795 kIs this ok [y/N]: yDownloading Packages:Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning Transaction Installing : screen-4.0.3-16.el6.x86_64 1/1 Installed products updated. Verifying : screen-4.0.3-16.el6.x86_64 1/1 Installed: screen.x86_64 0:4.0.3-16.el6 Complete![[email protected] yum.repos.d]# which screen/usr/bin/screen[[email protected] yum.repos.d]# 一、screen 的建立[[email protected] ~]# screen -lsNo Sockets found in /var/run/screen/S-root.[[email protected] ~]# [[email protected] ~]# [[email protected] ~]# screen -dmS lei1[[email protected] ~]# screen -lsThere is a screen on: 5786.lei1 (Detached)1 Socket in /var/run/screen/S-root.[[email protected] ~]#其中:5786是linux的ospid。lei1是会话的名称。二、screen 的进入[[email protected] ~]# screen -r lei1三、暂时退出某个screen 的session :先按ctrl ,再按小写的a,再按小写的d[[email protected] ~]# [detached][[email protected] ~]# 四、若是本来就在该session中,再使用screen -r lei1命令时的提示:[[email protected] ~]# screen -r lei 或者用screen -r 5786There is a screen on: 5786.lei1 (Attached)There is no screen to be resumed matching lei.[[email protected] ~]# 五、状态解释:[[email protected] ~]# screen -dmS lei2[[email protected] ~]# [[email protected] ~]# [[email protected] ~]# [[email protected] ~]# screen -lsThere are screens on: 5850.lei2 (Detached)---->挂起状态,无终端在连接会话 5786.lei1 (Attached)---->有终端在连接会话。2 Sockets in /var/run/screen/S-root.[[email protected] ~]# 六、永久退出screen中的本session[[email protected] ~]# exit exit [screen is terminating][[email protected] ~]# screen -lsThere is a screen on: 5850.lei2 (Detached)1 Socket in /var/run/screen/S-root. 七、检查screen中的其他session的来源ip:[[email protected] ~]# who -a system boot 2015-03-19 12:36 run-level 5 2015-03-19 12:36LOGIN tty2 2015-03-19 12:37 1979 id=2LOGIN tty4 2015-03-19 12:37 1983 id=4LOGIN tty3 2015-03-19 12:37 1981 id=3LOGIN tty5 2015-03-19 12:37 1985 id=5LOGIN tty6 2015-03-19 12:37 1987 id=6root + pts/0 2015-03-19 19:05 00:17 5306 (192.168.80.1) pts/1 2015-03-19 22:29 5787 id=/1 term=0 exit=0 pts/2 2015-03-19 22:33 5810 id=ts/2 term=0 exit=0root + pts/3 2015-03-19 22:33 . 5830 (192.168.80.1)root + pts/4 2015-03-19 22:42 00:11 5851 (192.168.80.1:S.0)---->注意此处[[email protected] ~]# screen -lsThere is a screen on: 5850.lei2 (Attached)1 Socket in /var/run/screen/S-root.[[email protected] ~]# ps -ef | grep 5851---->注意此处root 5851 5850 0 22:33 pts/4 00:00:00 /bin/bashroot 5974 5830 0 22:56 pts/3 00:00:00 grep 5851[[email protected] ~]# ps -ef | grep 5850---->注意此处root 5850 1 0 22:33 ? 00:00:00 SCREEN -dmS lei2 ---->注意此处root 5851 5850 0 22:33 pts/4 00:00:00 /bin/bash ---->注意此处root 5883 5810 0 22:42 pts/2 00:00:00 screen -r 5850[[email protected] ~]# 八、检查当前的提示符是否处于screen的session中:按ctrl,再按a,再按t此时,在左下角会显示:“22:45:06 Mar 19 rhel63single 0.00 0.00 0.00” 字样格式为:当前时间,日期,主机名,负载情况九、杀掉screen中的其他session[[email protected] ~]# kill -9 5850[[email protected] ~]# screen -lsThere is a screen on: 5850.lei2 (Dead ???)Remove dead screens with 'screen -wipe'.1 Socket in /var/run/screen/S-root.[[email protected] ~]# screen -wipeThere is a screen on: 5850.lei2 (Removed)1 socket wiped out.No Sockets found in /var/run/screen/S-root.[[email protected] ~]# screen -lsNo Sockets found in /var/run/screen/S-root.[[email protected] ~]# 然后,被杀掉的session 有提示:[[email protected] ~]# Suddenly the Dungeon collapses!! - You die...[[email protected] ~]#
(以上内容不代表本站观点。) --------------------------------- |