title: How to write console output to a text file with Rscript, like you can with R CMD BATCH
body: <p>In the past I have used <code>R CMD BATCH</code> to execute R code from the command line on a Linux server. The syntax I used was</p>
  <pre><code>R CMD BATCH --no-save --no-restore rcode.r output.txt
  </code></pre>
  <p>The above code writes console output to <code>output.txt</code> which can be monitored as the script is running. Is this also possible with <code>Rscript</code>? I would prefer to use <code>Rscript</code> since I have heard that <code>R CMD BATCH</code> is deprecated.</p>
  <p>To clarify my original question, <code>R CMD BATCH</code> writes all console output, including messages, warnings, and <code>print()</code> statements, to <code>output.txt</code>. In contrast <code>Rscript rcode.r &gt; output.txt</code> writes only the <code>print()</code>ed output to the text file and everything else to the terminal. How can I replicate the behavior of <code>R CMD BATCH</code> with <code>Rscript</code>?</p>