Skip to content

Instantly share code, notes, and snippets.

@stringfellow
Created July 12, 2012 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stringfellow/3097173 to your computer and use it in GitHub Desktop.
Save stringfellow/3097173 to your computer and use it in GitHub Desktop.
Bash wrapper script to silence cron if there are no errors, and print out if there are
#!/bin/bash
logfile=$$.log
exec 6>&1
exec > $logfile 2>&1
$*
RETVAL=$?
exec 1>&6 6>&-
if [ $RETVAL -ne 0 ]; then
echo "FAILURES:"
cat $logfile
fi
rm $logfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment