bash - 当后台进程结束时, `+` 之前的 `-` 、 ` ` 和 `Done` 符号是什么意思?

标签 bash shell parallel-processing

问题

当后台进程结束时,Done 之前的 +- 符号的含义是什么?

感兴趣的例子

代码 1

(sleep 4s; echo first)&
(sleep 2s; echo second)&
(sleep 1s; echo third)&

[1]   Done                    ( sleep 4s; echo first )
[2]-  Done                    ( sleep 2s; echo second )
[3]+  Done                    ( sleep 1s; echo third )

代码 2

(echo first)&
(echo second)&
(echo third)&

[1]+  Done                    ( echo first )
[2]+  Done                    ( echo second )
[3]+  Done                    ( echo third )

最佳答案

我的理解是:

1- 已标记或具有 + 的作业是最后发送到后台的作业。

2- 作业被标记或具有 - 被发送到后台倒数第二个。

3- 其他后台作业未标记。

这是我刚刚在我的系统上运行的例子

$bash: /singh/test1 &
[1] 9223
$bash:  /singh/test2 &
[2] 9226
$bash:  /singh/test3 &
[3] 9234
$bash:  /singh/test4 &
[4] 9237
$bash:  jobs
[1]   Running                 /singh/test &
[2]   Running                 /singh/test2 &
[3]-  Running                 /singh/test3 &
[4]+  Running                 /singh/test4 &

我可以从人身上看到 bash:

There are a number of ways to refer to a job in the shell. The character % introduces a job specification (jobspec). Job number n may be referred to as %n. A job may also be referred to using a prefix of the name used to start it, or using a substring that appears in its command line. For example, %ce refers to a stopped ce job. If a prefix matches more than one job, bash reports an error. Using %?ce, on the other hand, refers to any job containing the string ce in its command line. If the substring matches more than one job, bash reports an error. The symbols %% and %+ refer to the shell’s notion of the current job, which is the last job stopped while it was in the foreground or started in the background. The previous job may be referenced using %-. If there is only a single job, %+ and %- can both be used to refer to that job. In output pertaining to jobs (e.g., the output of the jobs command), the current job is always flagged with a +, and the previous job with a -. A single % (with no accompanying job specification) also refers to the current job.

关于bash - 当后台进程结束时, `+` 之前的 `-` 、 ` ` 和 `Done` 符号是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48837611/

相关文章:

linux - Centos 7,未找到 ImageMagick 命令

bash - 如何使用 bash shell 计算功率值

c# - 任务层次结构示例未按预期工作

c# - 如何并行读取队列中的消息?

windows - 在 Windows 上的 MobaXterm Home 下启动时不读取本地 .bashrc

java - 在 bash 中传递文件参数

c++ - 如何使用 boost::iostreams 将 bash 脚本转换为 C++

bash - 为什么 bash4 以不同方式扩展花括号?

linux - 删除行的第一部分,直到找到字符@

python - 当我使用 np.power() 时,如何在 numba 中设置 `parallel=True`?