LinuxCtrl + zjobsbgfg usage and differences

Source: Internet
Author: User
LinuxCtrl + zjobsbgfg usage and differences 1. & amp; this is most often used at the end of a command, you can run this command in the background. 2. ctrl + z. You can run a command in the foreground on the background, pause. 3. run jobs to check the number of Linux Ctrl + z jobs bg fg running in the background. 1. & This command is most often used at the end of a command, you can run this command in the background. 2. ctrl + z. You can run a command in the foreground on the background, pause. 3. run jobs to check the number of commands currently running in the background. 4. run the command in the background to the foreground. if there are multiple commands in the background, you can use fg % jobnumber to call up the selected command. % jobnumber is the serial number of the command being executed in the background (not pid) found through the jobs command) 5. bg changes a command paused in the background to continue execution. if there are multiple commands in the background, you can use bg % jobnumber to call up the selected command. % jobnumber is run through jobs. The serial number (not pid) of the command being executed in the background. in Linux, run the Shell command to control the job Jobs and run the following command to manipulate the process task: ps to list the running processes in the system; kill sends signals to one or more processes (often used to kill one process). jobs list the status of started tasks in the current shell environment. if jobsid is not specified, the status information of all active tasks is displayed. if a task is Terminated (that is, the task status is marked as Terminated ), shell deletes the process ID of a task from the list of known shell environments; bg moves the process to the Background for running; fg moves the process to the Foreground for running (Foreground ); transfer the job to the background. if you often work in X graphics, you may have the following experience: run a GUI program through terminal commands, and the GUI is displayed, however, your terminal remains in the same place. you cannot execute other commands in shell unless you turn off the GUI program. To enable the terminal to continue to accept commands after the program is executed, you can move the process to the background and run the program using the following command: # suppose you want to run xmms $ xmms & open xmms in this way, the terminal prompt is returned. Currently, xmms is running in the background. However, if you forget to use "&" when running the program and do not want to execute it again, you can use ctrl + z to suspend the program first, then, press the bg command to continue running the program in the background. Concept: if the current task has two backend task numbers: [1], [2]. if the first background task is successfully executed, the second background task is still in progress, the current task automatically becomes a background task with the background task number "[2. So we can conclude that the current task will change. When you enter commands such as "fg", "bg", and "stop", if no quotation marks are added, all changes are made to the current task. You can view jobs that are being executed by running jobs or ps commands. The result of running the jobs command. + indicates a current job. 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 state. However, if the task is Terminated (kill), the 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 the tasks that are running or suspended in the background in the current shell environment. the pending background processes: run the stop command in solaris, run the jobs command to view the job number (assuming num) and run stop % num. in redhat, the stop command does not exist. you can run the command kill-stop PID to suspend the process; when you want to re-execute the currently suspended job, you can use bg % num to change the status of the suspended job from stopped to running and still run in the background. when you need to re-execute the job on the foreground, execute command fg % Num; foreground process suspension: ctrl + Z; process termination background process termination: Method 1: run the jobs command to view the job number (assuming num ), run kill % num. Method 2: run the ps command to view the job process ID (PID, which is assumed to be pid), and then run kill pid to terminate the foreground process: ctrl + ckill other functions kill not only can terminate the process, but also can send other signals to the process. use kill-l to view the signals supported by kill. SIGTERM is a signal sent by kill without parameters. it means that the process must be terminated, but whether the process is executed or not depends on whether the process is supported. If the process has not been terminated, you can use the kill-SIGKILL pid, which is terminated by the kernel. The process cannot listen to this signal.
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.