Switching between a Linux task and a front desk

Source: Internet
Author: User

Shell support function control, with the following command to achieve the front and rear switch: 1. command& let the process run in the background 2. Jobs view Process 3 running in the background. FG%n Let the background run the process N to the foreground to 4. BG%n Let the process n Go backstage
5. Kill%n kills Job PS: "N" is the job number that the jobs command sees, not the process number. FG, BG, Jobs, &, CTRL + Z are all related to system tasks, although it is not necessary to use these commands, but learning is also very practical.

One, & most often used this is used at the end of a command, you can put this command in the background to execute

Two, CTRL + Z can put a command executing in the foreground in the background, and pause

Iii. jobs See how many commands are currently running in the background

FG will move the command in the background to the foreground to continue running if there are multiple commands in the background, you can use FG%jobnumber to bring up the selected command,%jobnumber is the ordinal (not PID) of the command being executed in the background through the jobs command.

BG will be a command paused in the background to continue execution if there are multiple commands in the background, you can use BG%jobnumber to bring up the selected command,%jobnumber is the serial number (not the PID) of the command being executed in the background through the jobs command.

Example: Suppose you find that a program running in the foreground takes a long time, but you need to do something else, you can use CTRL-Z to terminate the program, and then you can see the system prompt: [1]+ Stopped./start.sh If you do not have this prompt, use the jobs command to view the task: # jobs[1]+ suspended./start.sh & then we can schedule the program to execute in the background: (the number behind BG is the job number) #bg 1[1]+./start.sh & View running tasks with the jobs command: #jobs [1] + Running./start.sh & If you want to bring it back to the foreground, you can use #fg 1./start.sh so that you can only wait for this task to complete on the console.

Switching between a Linux task and a front desk

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.