Archive for July 2012

Linux Tip: Output error messages to syslog from cron

I wanted to find a way of running a script in cron and output the exit code, and error message, to syslog if it failed. Here’s what I came up with… ?View Code BASHoutput=`/usr/bin/scripts/test.sh 2>&1`; code=$?; if [ "$code" -ne 0 ]; then err_msg=`echo "$output" | tail -1`; logger -t "CRONERROR" "Exit Code = $code: […]