Created
April 17, 2020 13:02
-
-
Save pkoch/3619659c2e9c5a3e8fb7b81bc5f15eec to your computer and use it in GitHub Desktop.
This file contains hidden or 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