-
-
Save juliosantos/bbcc3c70fa50ee7f33f9a2517be6a787 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# pkoch: I've removed the trace funcionality, unified outputs, and only send email on non-zero result. | |
# Cronic v3 - cron job report wrapper | |
# Copyright 2007-2016 Chuck Houpt. No rights reserved, whatsoever. | |
# Public Domain CC0: http://creativecommons.org/publicdomain/zero/1.0/ | |
set -eu | |
TMP=$(mktemp -d) | |
OUT=$TMP/cronic.out | |
set +e | |
"$@" >$OUT 2>&1 | |
RESULT=$? | |
set -e | |
if [ $RESULT -ne 0 ]; then | |
echo "Cronic detected failure or error output for the command:" | |
echo "$@" | |
echo | |
echo "RESULT CODE: $RESULT" | |
echo | |
echo "OUTPUT:" | |
cat "$OUT" | |
fi | |
rm -rf "$TMP" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment