Why didn't the shell command execute in order as I expect?

后端 未结 4 1741
暗喜
暗喜 2021-01-28 16:21

I have written 3 shell scripts named s1.sh s2.sh s3.sh. They have the same content:

#!/bin/ksh
echo $0 $$

and s.sh invoke them in order:

<
4条回答
  •  情话喂你
    2021-01-28 17:18

    The & operator places each exec in the background. Effectively, you are running all 3 of your scripts in parallel. They don't stay in order because the operating system executes a bit of each script whenever it gets a chance, but it is also executing a bunch of other stuff too. One process can be given more time to run than the others, causing it to finish sooner.

提交回复
热议问题