What is difference between a job and a process in Unix?

后端 未结 8 1318
别跟我提以往
别跟我提以往 2021-02-02 10:53

What is the difference between a job and a process in Unix ? Can you please give an example ?

8条回答
  •  生来不讨喜
    2021-02-02 11:37

    A Process Group can be considered as a Job. For example you create a background process group in shell:

    $ find $HOME|sort &
    [1] 2668
    

    And you can see two processes as members of the new process group:

    $ ps -p 2668 -o cmd,pgrp 
    CMD                          PGRP
    sort                         2667
    
    
    $ ps -p "$(pgrep -d , -g 2667)" -o cmd,pgrp
    CMD                          PGRP
    find /home/juergen           2667
    sort                         2667
    

    You can can also kill the whole process group/job:

    $ pkill -g 2667
    

提交回复
热议问题