首页 > shell中的jobs和process有什么区别?

shell中的jobs和process有什么区别?

各位好:

如题所示,我理解jobs可能是各种应用程序,一个jobs可以对应多个process,这么说对不对? 更准确点的解释应该是什么?

非常感谢!


What is the difference between a job and a process?
job是shell的概念,process是操作系统的概念。从一定程度上讲,你可以理解为job里可以有多个process。

比如运行:

$ tail -f test.txt | more &
[1] 32751
$ jobs
[1]+  Running               tail -f test.txt | more
$ ps af
  PID TTY      STAT   TIME COMMAND
32740 pts/1    Ss     0:00 -bash
32750 pts/1    T      0:00  \_ tail -f test.txt
32751 pts/1    T      0:00  \_ more
32752 pts/1    R+     0:00  \_ ps af
  762 tty2     Ss+    0:00 /sbin/getty 38400 tty2
  760 tty1     Ss+    0:00 /sbin/getty 38400 console

可以看到只启动了一个job,但存在tailmore两个process。

你可以阅读一下Understanding Job Control In Bash

【热门文章】
【热门文章】