How to run the program in the background or from the background to the foreground in linux

Source: Internet
Author: User


For example, I need to decompress Or compress another 70 GB object. I can't always open a terminal. If I keep on a terminal, if the transfer is half done, I need to cut off the power or cut off the network, you are finished, so we can put her on the terminal to run: @ #: nohup your shell command & example: nohup tar-zxvf/var/www/html.tar.gz & this command will generate a nohup log Example 2: Check whether the work in the background has been completed or transferred to the foreground for running: use jobs to view tasks. Disable using fg % n. Two other ftp tools, ncftpget and ncftpput, can be used to upload and download files in the background through ftp, so that I can use these commands to upload and download files in the background. 5. the function of the fg command is to port the specified background job to the foreground. The format is: fg [job...] here, the parameter job is the PID of one or more processes, or the command name or job number (with a % sign in front) $ jobs [2] + running tar tv3 * & [1]-running find/-name README-print> logfile & $ fg % find/-name README-print> logfile note, no & symbol at the end of the displayed command line. the following command produces the same effect: $ fg % 1 6. the bg command is used to switch the foreground process to the background for execution. The format is: bg [job...] here, the job is also the PID of one or more processes, command name or job number, with the "%" sign before the parameter. for example, when executing the cc (C compilation command) command, press the Z key to suspend the job. run the following command: $ bg % cc. The suspended job is restarted in the background. Start running ......... then, add several UNIX process management commands. ps command-mainly checks the existing process status in the system. to understand the information of active processes on the current system, the most basic operation is to run the ps command. when the ps command has no options, only basic information about the processes related to the control terminal is displayed. for example, on the master control tty01, type ps: $ ps pid tty time cmd 595 tty01 00:00:00 sh 607 tty01 00:00:00 ps where PID -- is the ID of the Process TTY -- terminal identifier TIME -- CPU usage TIME of the Process CMD -- sleep command corresponding to the Process command is to suspend the process for a period of time, the parameter unit is second. for example, $ sleep 60 indicates that the system will return to the $ prompt status after 60 seconds. the wait command is used to wait for the background process to complete. the command format is: $ wait is followed by the kill command to terminate the running of a process. if you are a Super User: $ kill 12 3 is to stop a process with a PID of 123. If you want to forcibly kill a process (specified by the PID), you can use the following format: # kill-9 pid supplement: The at Command requires the ROOT permission. Ps-ef lists all ongoing processes! Ps-ef | grep xxx: query the process author lonleyemperor who contains xxx in the process

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.