title: How to exit from a command after n seconds?
body: <p>I'm writing a script and would like to know how to ask one of the commands to exit after few seconds. For eg. let's suppose my script runs 2 application commands in it.</p>
  
  <pre><code>#!/bin/bash
  
  for i in `cat servers`
  do
  &lt;command 1&gt; $i &gt;&gt; Output_file  #Consistency command
  &lt;command 2&gt; $i &gt;&gt; Output_file  #Communication check
  done
  </code></pre>
  
  <p>These commands are to check consistency &amp; communication to/from application. I want to know how do I make sure that command 1 &amp; 2 runs for only few seconds and if there is no response from particular host, move on to next command.</p>