I have a cron job configured this way in my crontab:
*/1 * * * * sudo /home/pi/coup/sensor.py >> /home/pi/sensorLog.txt
It puts stdout in the sensorLog.txt file, and any stderr that it creates is placed in the email.
I want stdout and stderr to go into sensorLog.txt, so I added 1>&2to crontab, which should make stderr in the same place as stdout. Now it looks like this:
*/1 * * * * sudo /home/pi/coup/sensor.py >> /home/pi/sensorLog.txt 1>&2
Now both stdout and stderr both go to the email and nothing is added to the file. This is the opposite of what I'm trying to accomplish.
How to make stdout and stderr redirect to a file?
source
share