title: Redirect stdout and stderr in real time
body: <p>I think that's an easy question but couldn't find the solution. I redirect the stdout and stderr of ruby script doing 'puts' and sometimes errors (!) to a log file like this :</p>
  
  <pre><code>bundle exec rake import:long_task --trace  &gt;&amp; log/import.log &amp;
  </code></pre>
  
  <p>But it doen't seem to flush the <code>puts</code> in realtime to the file and when its get an exception it puts the traceback in the top <code>import.log</code>. So, that's not perfect to debug but it works.</p>
  
  <p>How I can redirect the output of a script in realtime to a file to see exactly what I would have seen if I have launch it directly in the terminal without redirecting ?</p>
  
  <p>Using: Ruby 1.9.2, Rails 3.2, FreeBSD and csh shell.</p>