title: terminate infinite loop initiated in remote server when exiting bash script
body: <p>Script which executes commands in infinite loop in background</p>
  
  <pre><code>&lt;SOMETHING ELSE AT START OF SCRIPT&gt;
  
  cmd='while true;
  do
      ps aux | head;
      sleep 1;
  done &gt; $FILE'    
  
  ssh root@$SERVER $cmd &amp;
  ...
  ...
  &lt;SOME OTHER TASKS&gt;
  ...
  ...
  ( at the end of this script, how to kill the above snippet executing in remote server)
  [ kindly note i dont want to wait as the while loop is infinite ]
  </code></pre>
  
  <p>Read and tried some posts from stackoverflow, but could not find exact solution for this problem.</p>