Skip to content

Instantly share code, notes, and snippets.

@juliosantos
Forked from pkoch/cronic
Last active November 18, 2020 01:41
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 juliosantos/bbcc3c70fa50ee7f33f9a2517be6a787 to your computer and use it in GitHub Desktop.
Save juliosantos/bbcc3c70fa50ee7f33f9a2517be6a787 to your computer and use it in GitHub Desktop.
#!/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