title: How do I limit the running time of a BASH script
body: <p>I have a long running BASH script that I am running under CYGWIN on Windows.</p>
  
  <p>I would like to limit the script to run for 30 seconds, and automatically terminate if it exceeds this limit. Ideally, I'd like to be able to do this to any command.</p>
  
  <p>For example:</p>
  
  <pre><code>sh-3.2$ limittime -t 30 'myscript.sh'
  </code></pre>
  
  <p>or </p>
  
  <pre><code>sh-3.2$ limittime -t 30 'grep func *.c'
  </code></pre>
  
  <p>Under cygwin the ulimit command doesn't seem to work. </p>
  
  <p>I am open to any ideas.</p>