How to Control foreground and background tasks in Linux

Source: Internet
Author: User
Article Title: how to control tasks in the front and back of Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Linux/Unix is different from Microsoft's platform. The biggest advantage is the real multi-user, multi-task. Therefore, there are also special management ideas in task management.

We know that in Windows, we either have a program running on 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 you to easily schedule running tasks.

Suppose you find it takes a long time to run a program on the front end, but you need to do other things, you can use Ctrl-Z to terminate the program, and then you can see the system prompt:

[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 running tasks:

# Jobs

[1] + Running/root/bin/rsync. sh &

If you want to call it back to the foreground, you can use

# Fg 1

/Root/bin/rsync. sh

In this way, you can only wait for the task to be completed on the console.

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.