Screen Introduction Screen is a free software developed by the GNU project for command line terminal switching. Users can use this software to connect to multiple local or remote command line sessions at the same time and switch between them freely. GNU Screen can be thought of as a command-line interface version of a window manager. It provides a unified interface and corresponding functions for managing multiple sessions. Official website: http://www.gnu.org/software/screen/ GUN Screen: In the Screen environment, all sessions run independently and have their own number, input, output, and window buffer. Users can switch between different windows using shortcut keys and can freely redirect the input and output of each window. Screen Syntax
Importance of screen The importance of screen lies in the fact that it can run on the server all the time without stopping as long as the server is not down or without power outage. In fact, backend engineers often encounter the situation where they need to process some data by executing scripts, but this script may take half a day or several days to execute. Screen is the best choice. After a while, log in to the server to check the running status and whether it has been completed. It is not finished and continues to run. Common parameters of screen The screen command has many parameters. We will only look at the ones that are commonly used.
In each screen session, all commands start with ctrl+a.
Use of screen First simulate a script code that takes a long time to execute test.php <?php sleep(10000); echo 111; ?> The program sleeps for 10000 seconds and then outputs 1111 First create a screen, then execute it and log out screen -S test php test.php Create a screen named test and execute test.php after entering the screen. Then let the script execute in the screen all the time, and press Ctrl+ad to let the script execute in the background of the screen. screen -S test [detached from 3934.test] exit Log out, wait for a while and then log in again to check if the script is still executing ssh screen -ls There are screens on: 3934.test (02/25/2020 10:27:06 PM) (Detached) The screen ID of test is 3934. Connect to the screen and enter screen -r 3934 php test.php You can see that the test.php script is still executing. Execute ctrl+az to execute the script in the background, and then use fg to bring it to the foreground [1]+ Stopped screen -r 3934 Execute fg php test.php Let's look at screen -d and -D Reopen a window, ssh, and execute screen -d 3934 [3934.test detached.] Then check the previous window to see if the screen is disconnected. screen -r 3934 [remote detached from 3934.test] Look again, -D, in the first window In the second window, execute -D screen -D 3934 [3934.test power detached.] Looking at the first window again, you have been forced to log out. screen -r 3934 [remote power detached from 3934.test] Connection to 127.0.0.1 closed. As a developer, you only need to know three commands to meet more than 90% of the usage scope in normal development. screen -ls screen -S screen -R ctrl+ad Common screen operations Create a session (-m forced): screen -dmS session_name # session_name session name Close the session: View all sessions: Enter the session: Summarize This is the end of this article about the screen command in Linux and how to use it. For more information about the linux screen command, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: jQuery implements simple button color change
>>: MySQL 5.7.27 installation and configuration method graphic tutorial
For many domestic advertisers, the creation and ev...
1. Command Introduction bzip2 is used to compress...
1. I searched for a long time on the Internet but...
Preface The gradient of the old version of the br...
MySQL is the most commonly used database. You mus...
Table of contents Preface Centering inline elemen...
I will explain the installation of MySQL under Wi...
The vue part is as follows: <template> <...
The first time I wrote a MySQL FUNCTION, I kept g...
Table of contents 1. Check the MySQL status in th...
Without further ado, I will post the code for you...
The Flexbox layout module aims to provide a more ...
I want to use the marquee tag to set the font scro...
Table of contents Overview Code Implementation Si...
After setting up the MySQL master-slave, you ofte...