title: Increment Counter in a while loop after X seconds
body: <p>I am trying to run a script which takes input from text file and based on the number of entries in it, a command is executed as many number of times. 
  Below is an overview:</p>
  
  <pre><code>cat /tmp/file.txt | while read name
  do
  &lt;&lt;execute a command using value of $name&gt;&gt;
  done
  </code></pre>
  
  <p>What is happening is sometimes the command executed for particular $name is getting hung due to known issues. Therefore I need in such cases that the command on every value of $name runs only for X number of seconds and if it is not able to complete within that stipulated time, terminate the process and increment loop counter. 
  I was able to make use of sleep and kill but it is terminated the entire loop. I want the next values to be processed in case command gets hung on a row/value.
  Please advise. </p>