Linux process frontend and backend switch

Source: Internet
Author: User
In a linux process, the frontend and backend switches. when you use shell to start a program, it usually works in the foreground. For example, when you often use PUTTY to connect to a remote server to execute scripts, if the local network is interrupted, the foreground process will end. in this case, you must re-execute the script. Therefore, it must be...
In a linux process, the frontend and backend switches. when you use shell to start a program, it usually works in the foreground. For example, when you often use PUTTY to connect to a remote server to execute scripts, if the local network is interrupted, the foreground process will end. in this case, you must re-execute the script. Therefore, it is necessary to switch the frontend and backend processes. For example, if you enter firefox directly in the terminal, firefox will be turned on, but when you close this terminal or press ctrl + c to force termination, firefox will also be disabled at random. You can add an & at the end of the execution to work in the background. Shell supports role control and has the following commands: 1. command & let the process run in the background 2. jobs-l view the processes running in the background 3. fg % n let the background running process n to the foreground 4. bg % n let process n go to the background; www.2cto.com PS: "n" is the process number viewed by jobs. 1. run the command and switch to the background. when running the command on the Linux Terminal, add the & symbol at the end of the command to run the program root @ Ubuntu $ in the background. /tcpserv01 & 2. switch the running program to the background. if the program is running on the foreground, you can use the Ctrl + z option to pause the program, then run the program in the background using the bg % [number] command. The steps are divided into three steps: 2.1 pause the program running CTRL + Zctrl + z related to the system task, ctrl + z can put a command being executed on the foreground to the background and pause it. [Oracle @ isgis121 ~] $ Sh ins. sh ^ Z [1] + Stopped ins. sh2.2 view the suspended program. check that jobs are being executed by running jobs or ps commands. [Oracle @ isgis121 ~] $ Jobs-l [1] + 4524 Stopped ins. shjobs command execution result, + indicates a current job, and the minus table is a job after the current job. The jobs-l option displays the PID of all tasks. jobs can be in the running, stopped, and Terminated www.2cto.com 2.3 Status. when the program is switched to the background bg, a command is paused in the background, if there are multiple commands in the background, use bg % jobnumber to call up the selected command. [oracle @ isgis121 ~] $ Bg % 1 [oracle @ isgis121 ~] $ Jobs-l [1] + 4524 Running ins. sh2.4 to switch the program to the foreground, you can also use the command fg % [number] to drop a program to the foreground and run [oracle @ isgis121 ~] $ Fg % 1./tcpserv01 2.5 terminate the background program or directly terminate the program running in the background. run the kill Command [oracle @ isgis121 ~] $ Kill % 1 but if the task is terminated (kill), shell deletes the process ID of the task from the list known in the current shell environment; that is, the jobs command displays information about running or suspended tasks in the background in the current shell environment.
Related Article

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.