2010-06-21 208 views
1

我想開始一段python腳本一千次!而不是試圖逐一啓動它們,我怎麼能從linux命令行來做到這一點?提前從linux命令行一次啓動多個python腳本實例

nohup python test.py & 
nohup python test.py & 
nohup python test.py & 
nohup python test.py & 
nohup python test.py & 
... 

感謝:

現在,我這樣做是這樣的。

回答

7

作爲一個內膽,在擊:

for i in {1..1000}; do nohup python test.py & done 
2

最簡單的就是讓使用shell腳本一個循環,這會爲任何工作:

#!/bin/bash 
X=0 
COUNT=1000 
while [ $X -lt $COUNT ]; do 
    nohup python test.py & 
    X=$((X+1)) 
done 
+3

一個'for'循環會更簡單。 (for i in {1..1000}'或'for((i = 0; i <1000; i ++))'或Bourne shell:'for in in $(seq 1000)'' – 2010-06-21 10:53:27

4

我建議你保持產卵邏輯的Python程序。也許使用multiprocessing庫來完成這些過程。如果你打算用bash產生它們,如果沒有一些不平凡的腳手架,將很難管理所有這些。