In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Introduction to Screen
Screen is a free software developed by GNU for command line terminal switching. Through the software, users can connect multiple local or remote command line sessions at the same time and switch freely between them. GNU Screen can be thought of as the command-line interface version of the window manager. It provides a unified interface for managing multiple sessions and corresponding functions.
Official website: http://www.gnu.org/software/screen/
GUN Screen:
In the Screen environment, all sessions run independently and have their own numbers, inputs, outputs, and window caches. Users can switch between different windows through keyboard shortcuts, and are free to redirect the input and output of each window.
Screen syntax
Screen [- AmRvx-ls-wipe] [- d] [- h] [- r] [- s] [- S]-A resizes all windows to the size of the current terminal. -d takes the specified screen job offline. -h specifies the number of buffer rows for the window. -m forces the creation of a new screen job even if it is already in the job. -r resumes offline screen jobs. -R first attempts to resume offline jobs. If an offline job cannot be found, a new screen job is created. -s specifies the shell to be executed when a new window is created. -S specifies the name of the screen job. -v displays version information. -x resumes previously offline screen jobs. -ls or-- list displays all current screen jobs.
Importance of screen
The importance of screen is mainly reflected in that it can easily run on the server all the time, as long as the server is not down and there is no power outage, it does not have to stop. In fact, back-end engineers often encounter that they have to process some data by executing a script, but it may take half a day or a few days to execute this script. Screen is the best choice. Log in to the server after a period of time to check whether the running status is complete. It's not finished. Hang it up and continue running.
Parameters commonly used in screen
The screen command has a lot of parameters, so let's take a look at the more commonly used ones.
The parameter indicates that ls lists all the current reply S capitalized S, and creates a new session named xxx. R disconnects a session by serial number connection process session ddetach, which is the same as the-d command, but will logout the user who was originally in the screen.
In each screen session, all commands begin with ctrl+a
Parameter description ctrl+a ddetach session, throw the current screen session to the background for execution, and return to the state before entering the screen. Screen continues to execute, even if logout does not affect the execution of the background ctrl+a k forcibly closes the current window ctrl+a z puts the current session to the background for execution, and can be called back with the fg command
Screen usage
First simulate a script that needs to be executed for a long time
Test.php
The program sleeps for 10000 seconds and then outputs 1111
First create a screen, and then after executing it, log out of the login state
Screen-S testphp test.php
Create a screen named test, and execute test.php after entering screen. Then let the script execute all the time in screen, press Ctrl+a d to let the script execute in the background of screen.
Screen-S test [detached from 3934.test]
Log out of exit, wait a while and then log in to see if the script is still running.
Ssh screen-lsThere are screens on: 3934.test (02 Universe 25 Universe 10:27:06 PM) (Detached)
The screen ID named test is 3934, connect to the screen and enter
Screen-r 3934php test.php
You can see that the script for test.php is still executing.
Execute ctrl+a z, while the script is executed in the background, and then transferred to the foreground using fg
[1] + Stopped screen-r 3934 execute fgphp test.php
Take a look at screen-d and-D again.
Reopen a window, and after ssh, 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.
Screen-r 3934
The second window executes-D
Screen-D 3934 [3934.test power detached.]
Look again, the first window has been forced to log out.
Screen-r 3934 [remote power detached from 3934.test] Connection to 127.0.0.1 closed.
As a developer, in fact, you only need to know three commands to meet more than 90% of the scope of use.
Screen-lsscreen-Sscreen-Rctrl+a d
Common operations of screen
Create a session (- m force):
Screen-dmS session_name# session_name session name
Close the session:
Screen-X-S [session # you want to kill] quit
View all sessions:
Screen-ls
Enter the session:
Screen-r session_name
Summary
This is the end of this article on the screen command in Linux and how to use it. For more information about linux screen commands, please search for previous articles or continue to browse the relevant articles below. I hope you will support me in the future!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.