Screen implements the background running program
Screen implements the background running program Screen implements the background running program
Screen implements a simple step in the background running program:
Screen - ls: you can watch screen sessions
Screen - r ID: specifies which screen session to enter
The shortcut key used in the Screen command
Ctrl + a c: create a window
Ctrl + a w: window list
Ctrl + a n: next window
Ctrl + a p: last window
Ctrl + a 0-9: switch between the 0th window and the ninth window
Ctrl + a K (capitals) : close the current window, and switch to the next window (when out of the last window, the terminal automatically terminated, and return to the original state of shell)
Exit: close the current window and switch to the next window (when you exit the last window, the terminal automatically terminates and returns to the original shell state)
Ctrl + a d: continue to perform the current task, exit the current terminal, and return the shell command state before loading screen
Ctrl + a: the window list is different from w
For example, this is the first time that a person has a problem with the problem
【 1 】 reprinted
System administrators often require remote login servers
Then run some programs on the server
There was a time
To run for a long time (over 12 hours)
This is the exit from the remote management terminal if the program is not finished
The remote run program is likely to be lost
The usual solution is to order nohup
But nohup has a lot of problems
When you have the screen
All this has been solved
Type the command screen
Create a single window running with the shell
In this
You can run the program you need
Then Ctrl + a d exits the window that was created (back to the environment before it entered screen)
Then you tap into the command screen to create a new terminal window
In this way
You can build multiple Windows with shells (all of these Windows can run your own app)
This is how you exit the remote management window (into screen)
Your screen window doesn't close
It's not going to be a natural thing to do
Screen sessions can be seen with screen ls
You can enter the specific screen session specified by the sessionid with the screen -r sessionid
The last screen session is no longer used
Screen -r sessionid inside
The exit exit can
Unix/Linux tools: Screen command usage
Screen using the
Using screen is very simple. Just type screen in the SHELL and open a screen session.
At every screen session, all commands start with CTRL + a (c-a).
Now let me briefly introduce the basic commands
C-a c-> Create, open the new window
C-a n-> Next, switch to the Next window
C-a p->, the Previous window
More..
C-a c-a-> Other, switch between two Windows
C-a w-> Windows, lists the Windows that are already open
C-a 0-> switches to the 0th window
C - a 1.. 9-> switches to # 1.. 9 the window
C-a - > emits c-a in emacs, ve, bash, TCSH
C-a t-> Time, display current Time, and system load
C - a K (uppercase) - > kill window, forcing the current window to be closed
C-a [-> goes to copy mode and can be rolled back, searched, and searched in copy mode.
Copying is like using vi
C - b Backward, PageUp
C - f Forward, PageDown
H (uppercase) High, move the cursor to the top left corner
Low, move the cursor to the lower left corner
0 moved to the beginning of a line
At the end of the line $
W forward one word, move forward in words
B backward one word to word for the unit running backwards
The first time Space is marked as the starting point for the
mark area, and the second is the end
Esc to end the copy mode
C-a - > Paste,
Paste the content you just selected in copy mode
C - a? - > Help, a simple explanation
C - a d - > detach, current screen session (possibly multiple Windows)
Into the background When pressing the C - d put a screen session detach after, will come back to haven't into the state of the screen, at this point in the screen session in each window in the operation of the process (both in the foreground/background) in continue, even logout does not affect.
Next time login comes in:
Screen - ls -> shows all screen sessions
Screen - r [keyword] - > selects a screen session to resume the dialog
If there is an Attached sessions in screen - ls:
Screen - d [keyword] - > forces detach to "take over"
Example:
So with that said, let's use a practical example to end our study today.
After we start a screen, we then use Joe to edit a file, and then we can run Ctrl + a d when we need to leave at the moment, as shown below:
[becks @ec-base becks] $screen
[detached]
This time when we run the ps-e we can see that PTS / 2 this screen that I just ran is running Joe
6264 PTS / 2 00:00 bash
6354 PTS / 2 00:00 Joe
And when we come back and want to restore this session, just type screen - r, and when you have multiple sessions, the system will prompt you to select one, as follows:
[becks @ec-base becks] $screen - r
There are several suitable screens.
6263. PTS - 1.ec - base (Detached)
6382.
"" to resume one of them."
Enter the pid for the session to recover
[becks @becks] $screen - r 6263
If you want to exit the session of screen, just type the exit command, just like the exit shell, you will have the following prompt when you exit successfully
[screen is terminating]
【 2 】 reprinted
The Linux screen command is detailed
Function description:
Use Telnet or SSH remote login Linux, if the connection is abnormal interruption, reconnects, the system will open a new session, unable to restore the original session. The screen command can solve this problem. The Screen tool is a terminal multiplexer, which in essence means you can run multiple terminals using a single terminal window.
Grammar:
Screen [- AmRvx - ls - wipe] [-d < job name >] [-h < number > lines] [-r name > < homework] [-s] [-s < job name >]
Additional information:
Screen is a multi-window manager. The window here refers to a full-screen text mode. It is usually possible to use a screen program only when Telnet is logged in or an old-fashioned terminal is used.
Parameters:
- A will adjust all the Windows to the size of the current terminal.
-d < job name > will specify screen job to be offline.
-h < line number > specifies the buffer line number of the window.
-m still forces a new screen job, even if it's already done in the job.
-r < job name > to restore offline screen jobs.
-r is trying to get back to work offline. If you can't find an offline job, create a new screen job.
-s specifies the shell to execute when a new window is created.
-s < the job name > specifies the name of the screen job.
-v displays version information.
-x works offline before resuming.
- ls or - list shows all screen jobs currently.
- wipe check all screen jobs now and delete any screen jobs that you can't use.
Commonly used screen parameters:
Screen - S yourname-> and a new session called yourname
Screen - ls -> lists all the sessions currently available
Screen - r yourname-> returns to your name session
Screen - d yourname-> remote detach session
Screen - d-r yourname-> ends the current session and goes back to your name session
At every screen session, all commands start with CTRL + a (c-a).
C - a? - > Help, a simple explanation
C-a c-> Create, open the new window
C-a n-> Next, switch to the Next window
C-a p->, the Previous window
C - a 0.. 9-> switches to 0.. 9 the window
Ctrl + a [Space] -> is changed from Windows 0 to Windows 9
C-a c-a-> is switched between two recently used Windows
C - a x - > locks the current window and USES the user password to unlock it
C - d - > a detach, leave for the current session, to the current screen session (may contain multiple Windows) into the background, and will come back to haven't into the state of the screen, at this point in the screen session in each window in the operation of the process (both in the foreground/background) in continue, even logout does not affect.
C-a z-> puts the current session in the background and can be returned with the shell's fg command.
C-a w-> Windows, lists the Windows that are already open
C-a t-> Time, display current Time, and system load
C-a k-> kill window, and force off the current window
本文档为【Screen implements the background running program】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。