Linux bg and fg commands

Source: Internet
Author: User
We all know the bg and fg commands in Linux. on Windows, we either have a program running in the background as a service or stop the service. The program cannot be switched between the foreground and background. Linux provides fg and bg commands, allowing us to easily schedule running...
We all know the bg and fg commands in Linux. on Windows, we either have a program running in the background as a service or stop the service. The program cannot be switched between the foreground and background. Linux provides fg and bg commands, allowing us to easily schedule running tasks. Www.2cto.com suppose you find it takes a long time to run a program on the foreground, but you need to do other things, you can use Ctrl-Z to suspend the program, then you can see the system prompt (job number in square brackets): [1] + Stopped/root/bin/rsync. sh then we can schedule the program to the background for execution: (the number following bg is the job number) # bg 1 [1] +/root/bin/rsync. sh & run the jobs command to view the Running tasks: # jobs [1] + Running/root/bin/rsync. sh & if you want to call it back to the foreground, use # fg 1/root/bin/rsync. sh. in this way, you can only wait for the task to be completed on the console. Fg, bg, jobs, &, ctrl + z are all related to system tasks. although these commands are rarely used at present, they are also very practical. & This command is most often used at the end of a command. you can put this command in the background for execution 2. Ctrl + z can put a command that is being executed on the front-end to the background, and pause the three. Jobs: view the number of currently running commands in the background. Fg transfers the commands in the background to the foreground to continue running. if there are multiple commands in the background, you can use fg % jobnumber to call up the selected command, % jobnumber is the serial number (not pid) 5 of the command being executed in the background found through the jobs command. Bg pauses a command in the background and continues execution. if there are multiple commands in the background, you can call out the selected command with bg % jobnumber, % jobnumber is the serial number (not pid) of the command being executed in the background found through the jobs command)
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.