0

I have this script test.sh

#!/bin/bash
( cd . && sleep 5000 )

I execute with ./test.sh & and then run ps lax | grep test.sh

I now have 2 processes running...

0  1000  6883  6600  20   0  10600  1332 -      S    pts/2      0:00 /bin/bash ./test.sh
1  1000  6884  6883  20   0  10604   704 -      S    pts/2      0:00 /bin/bash ./test.sh
  • Why do I have two processes running and where does the second process come from?
  • Why don't I have two processes if I remove the cd ".." from the command?

Thanks for any explanation, I just don't get it and I think I'm lacking some basics here... or is this some vodoo? ;)

4

2 回答 2

7

在括号内分组一系列 bash 命令将在子 shell 中执行它们。

于 2013-07-17T12:49:02.830 回答
0

一起编写两个命令可能会给终端检测命令带来一些困难。也许您可以将其拆分为 2 个命令。

cd ...

sleep 5000
于 2013-07-17T12:45:46.360 回答