簡體   English   中英

bash腳本執行順序

[英]bash script order of execution

bash腳本中的行是按順序執行的嗎? 我沒有看到任何原因,但我真的是新手bash腳本,我有一些需要按順序執行的命令。

例如:

#!/bin/sh
# will this get finished before the next command starts?
./someLongCommand1 arg1
./someLongCommand2 arg1

是的...除非您不想在后台運行其中一個命令,否則將在下一個命令啟動之前完成。

是的,它們是按順序執行的。 但是,如果在后台運行程序,則在啟動backgrounded命令后立即執行腳本中的下一個命令。

#!/bin/sh
# will this get finished before the next command starts?
./someLongCommand1 arg1 &
./someLongCommand2 arg1 &

會導致腳本幾乎立即完成; 但是,從它開始的命令將不會完成。 (通過在名稱后面添加一個與號(&)來在后台啟動命令。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM