After exiting SSH in Linux, the command being executed will be interrupted. Even if the task is executed in the background, the output information will not be displayed the next time you enter ssh.
Screen simulates multiple windows. When you exit SSH, the tasks executed in screen are not affected. Next time you log on to SSH, you only need to switch to the specified screen window, the task execution process and result are displayed.
If you have been using a Windows server, you can enjoy this convenience.
Centos is directly installed through Yum install screen.
Create a screen window named windows1:
] # Screen-s windows1
Enter a new interface that is exactly the same as SSH, and execute any command in it. For example
] # Ping www.csdn.net
The Ping will continue. At this time, press Ctrl + A and then press d to "minimize" the window and return to the previous SSH interface.
View Current windows
] # Screen-ls
There is a screen on:
24502. windows1 (detached)
1 socket in/var/run/screen/S-root.
We can see that there is a window named windows1 in the background. At this time, you can directly close SSH, log on again, and execute screen-ls.
Open Window
] # Screen-r windows1
Or
] # Screen-r 24502
In the windows1 window, you can see that ping is still being executed and the process is running.
Press Ctrl + C to terminate the current process
Press Ctrl + D to end the current window and return it to ssh.
If multiple windows need to end, you can directly killall Screen