How to redirect stderr to a file in a cron job : <p>I've got a cron job that is set up like this in my crontab:</p>

<pre><code>*/1 * * * *  sudo /home/pi/coup/sensor.py  &gt;&gt; /home/pi/sensorLog.txt
</code></pre>

<p>It puts stdout into sensorLog.txt, and any stderr it generates gets put into an email. </p>

<p>I want both stdout and stderr to go into sensorLog.txt, so I added <code>1&gt;&amp;2</code> to the crontab, which is supposed to make stderr go into the same place as stdout.  It now looks like this:</p>

<pre><code>*/1 * * * *  sudo /home/pi/coup/sensor.py  &gt;&gt; /home/pi/sensorLog.txt 1&gt;&amp;2
</code></pre>

<p>Now, both stdout and stderr both get put into an email, and nothing gets added to the file.  This is the opposite of what I am trying to accomplish.</p>

<p>How do I get both stdout and stderr to get redirected to the file?</p>
