如何在bash脚本中超时?

时间:2012-10-29 03:08:29

标签: bash shell timeout

  

可能重复:
  Timeout a command in bash without unnecessary delay

所以这就是我想做的事情 -

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秒并且移动到下一个$文件,如何超时$ output?

我可以将stderr重定向到result.txt吗?

1 个答案:

答案 0 :(得分: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