title: how to stop tail -f command executed in sub shell
body: <p>I tried various steps from <a href="http://mywiki.wooledge.org/ProcessManagement" rel="nofollow">http://mywiki.wooledge.org/ProcessManagement</a> and <a href="http://mywiki.wooledge.org/BashFAQ/068My" rel="nofollow">http://mywiki.wooledge.org/BashFAQ/068My</a>  but I am unable to achieve is how to kill the tail -f command after certain time interval.</p>
  
  <p>my script:</p>
  
  <pre><code>#!/bin/bash
  
  function strt ()
  {
  command 1..
  command 2..
  }
  
  export -f strt
  su user -c 'set -e &amp;&amp; RUN_Server.sh &gt; server.log &amp;&amp; tail -f server.log &amp; pid=$! { sleep 20; kill $pid; } &amp;&amp; strt'
  
  exit 0.
  </code></pre>
  
  <p>I am trying to kill the pid of tail -f server.log and proceed to 'strt' which is small function to find if jboss server is started or not.</p>
  
  <p>on executing I get error as </p>
  
  <p>bash: -c: line 0: syntax error near unexpected token `{' .  </p>