How to redirect stderr to a file in a cron job

It’s the other way around: */1 * * * * sudo /home/pi/coup/sensor.py >> /home/pi/sensorLog.txt 2>&1 2>&1 will redirect standard error (2) to standard output (1) which -in turn – was redirected to your log file. So, at the end, both stderr and stdout will go to your sensorLog.txt

Today’s date, minus X days in shell script

For GNU date: date_222days_before_TodayYear=$(date –date=”222 days ago” +”%Y”) date_222days_before_TodayMonth=$(date –date=”222 days ago” +”%m”) date_222days_before_TodayDay=$(date –date=”222 days ago” +”%d”) For BSD date:: If you are using OS X or FreeBSD, use the following instead because BSD date is different from GNU date: date_222days_before_TodayYear=$(date -j -v-222d +”%Y”) date_222days_before_TodayMonth=$(date -j -v-222d +”%m”) date_222days_before_TodayDay=$(date -j -v-222d +”%d”) Source: BSD … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)