title: Introduce timeout in a bash for-loop
body: <p>I have a task that is very well inside of a bash for loop. The situation is though, that a few of the iterations seem to not terminate. What I'm looking for is a way to introduce a timeout that if that iteration of <code>command</code> hasn't terminated after e.g. two hours it will terminate, and move on to the next iteration.</p>
  
  <p>Rough outline:</p>
  
  <pre><code>for somecondition; do
     while time-run(command) &lt; 2h do
       continue command
     done
  done
  </code></pre>