Linux tips for using screen to manage your remote session

Source: Internet
Author: User
Tags session id ssh

Linux tips-Using screen to manage your remote sessions

When we remotely log on to a Linux server with SSH or telent, run some long tasks, we must wait for the task to complete before leaving the interface. The window cannot be closed or disconnected during this time. Otherwise, the process of this task will not be killed, all by halves, you need to perform the task again.

How to solve this problem?

The first is to understand several concepts:

Process group: A collection of one or more processes, each with a single process group ID, the ID of the process leader process

Session Duration: A collection of one or more process groups with a unique session-first process, session ID as the ID of the process

Session period can have a separate control terminal, the session with the control terminal connected to the first process called the control process, the current and terminal interaction process for the foreground process.

Hang up signal the default action is to terminate the program

When the terminal excuse detects a disconnect from the network connection, it sends the suspend signal to the control process

If the session-time preferred process terminates, the signal is sent to the foreground process group in the session period

When a process exit causes an orphaned process group to be generated, if any orphaned process group is in a stop state, send sighup and sigcont signals to all processes in the process group.

Therefore, when the network disconnects or the terminal window closes, the control process receives a SIGHUP signal exit, which causes the other processes to exit during the session

Method One: Nohup

#nohup Command &

Method Two: Screen

Creen is a window manager that can multiplex a physical terminal across multiple processes.

How to use:

(1), [xuefeng@ku6]# screen

Screen creates a full-screen window that executes the shell, and you can execute any shell as if it were in an SSH window.

(2), [Xuefeng@ku6] #screen VI ABC

Screen to create a separate window session to perform VI ABC, EXIT VI will exit the window

(3), you can also create a new window in the existing Screen session window, type c-a C in the current Sceen window, CTRL + A, and then press the C key. Re-control the programs that are running in each window.

For example, if you are editing vi/tmp/abc in a screen window, and then you need to do something else, you can type c-a d,screen in the screen window and you will be prompted to temporarily interrupt the session. Continue with the previous session, #screen-ls to view the session number. Reconnect the screen-r number.

Note : More wonderful tutorials Please pay attention to the triple computer tutorial section, triple Computer office group: 189034526 welcome you to join

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.