2012-10-29 75 views
0

可能重複:
Timeout a command in bash without unnecessary delay如何在bash腳本中超時?

原來這就是我想要做的事 -

for test in `ls Tests`; do 

for file in `ls FileFolder`; do 

output=`python devcap $test $file` 

echo $test $file $output >>result.txt 

done 

done 

如何超時的$輸出,如果它需要比說長5秒鐘,並移動到下一個$文件?

我可以將stderr重定向到result.txt嗎?

+1

http://stackoverflow.com/questions/687948/timeout-a-command-in-bash-without-unnecessary-delay – doublesharp

回答

0

試試這個:

for test in `ls Tests`; do 

for file in `ls FileFolder`; do 

output=`python devcap $test $file` 

sleep 5 

echo $test $file $output >>result.txt 

done 

done 
+0

我試過it.Its不工作。該代碼只是掛起了外殼,並沒有向前移動。 – user1738845

+0

您是否嘗試在代碼中添加睡眠5? btw我更新了我的答案 –