Linux Job control management

Source: Internet
Author: User

Bash can only manage its own work and not manage other bash's work, even the root user. Bash's work is divided into the foreground and the backstage.

We have only one bash environment, if you want to do more than one process at a time, then you can throw a job directly into the background.

Use "&" to drop commands directly into the background.

-- while true;  do echo a>/dev/null;d One &[1] 1778 #[1] indicates job number, 1778 indicates the loop process number PID---Jobs # jobs used to view the working status in the background [1]+ Running 
    
     while 
     true; Do 
     #[1] indicates that job number,+ represents the default fetch work and is also the work number that was recently placed in the background 
     echo a >/dev/
     null
     ;d One &
    


#后台有两个进程
-->vi AAAAA
[2]+ Stopped VI aaaaa
-
-->jbs-l #-l indicates that the process number PID is listed in addition to the list of job numbers and the commands we execute
[1]-1778 Running while true; do #[-] represents the second most recent task to be put in the background, if more than 3, there will be no more than +/-number
echo a >/dev/null;
Done &
The "+" behind [2]+ 35145 suspended:18 vi aaaaa #这里job number[2] indicates that job number [2] is the most recently executed command in the background.



#超过3个进程子后台
-->vi BB
[3]+ Stopped VI BB
-
-->jobs
[1] Running while true;
echo a >/dev/null;
Done &
[2]-Stopped VI aaaaa
[3]+ Stopped VI BB

#jobs的参数
    • -L means that the-l indicates that the process number PID is listed in addition to the list of job numbers and the commands we execute
    • -r lists running background tasks
    • -s lists background tasks for stopped status

-->jobs-l
[1] 1778 Running while true;
echo a >/dev/null;
Done &
[2]-35145 suspended:18 VI aaaaa
[3]+ 56362 suspended:18 VI bb
-
-->JOBS-LR
[1] 1778 Running while true;
echo a >/dev/null;
Done &
-->jobs-ls
[2]-35145 suspended:18 VI aaaaa
[3]+ 56362 suspended:18 VI bb
-

The background work to the foreground, you can use FG [%]+jobnumber, "%" can be omitted.

FG By default will have a plus sign to get to the front desk.

FG N to the job Number=n task to the front desk.

Linux Job control management

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.