diff options
| author | dumpfmprod <dumpfmprod@ubuntu.(none)> | 2010-11-07 12:08:45 -0500 |
|---|---|---|
| committer | dumpfmprod <dumpfmprod@ubuntu.(none)> | 2010-11-07 12:08:45 -0500 |
| commit | f5692dcbff94853078cb06ea63c881bb0588e297 (patch) | |
| tree | 619a3752dc752e4e621b2bb24f0ee81202faa59e /scripts | |
| parent | 2880c132823d7933a32b36c2dd5f251c43bc4856 (diff) | |
Added cronic script w/ logging modifications
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/cronic | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/scripts/cronic b/scripts/cronic new file mode 100755 index 0000000..80f1cad --- /dev/null +++ b/scripts/cronic @@ -0,0 +1,54 @@ +#!/bin/bash + +# Cronic v2 - cron job report wrapper +# Copyright 2007 Chuck Houpt. No rights reserved, whatsoever. +# Public Domain CC0: http://creativecommons.org/publicdomain/zero/1.0/ + +set -eu + +OUT=/tmp/cronic.out.$$ +ERR=/tmp/cronic.err.$$ +TRACE=/tmp/cronic.trace.$$ +LOGDIR=/var/log/cronic + +set +e +"$@" >$OUT 2>$TRACE +RESULT=$? +set -e + +PATTERN="^${PS4:0:1}\\+${PS4:1}" +if grep -aq "$PATTERN" $TRACE +then + ! grep -av "$PATTERN" $TRACE > $ERR +else + ERR=$TRACE +fi + +if [ $RESULT -ne 0 -o -s "$ERR" ] + then + echo "Cronic detected failure or error output for the command:" + echo "$@" + echo + echo "RESULT CODE: $RESULT" + echo + echo "ERROR OUTPUT:" + cat "$ERR" + echo + echo "STANDARD OUTPUT:" + cat "$OUT" + if [ $TRACE != $ERR ] + then + echo + echo "TRACE-ERROR OUTPUT:" + cat "$TRACE" + fi +fi + +# sbostler: write log for all job runs +SCRIPT=$(basename $1) +OUTLOG=$(date +"$LOGDIR/$SCRIPT.%Y-%m-%d__%T.log") +cat "$OUT" > $OUTLOG + +rm -f "$OUT" +rm -f "$ERR" +rm -f "$TRACE" |
