492
|
1 #!/usr/bin/env bash
|
|
2
|
|
3 # Mod by edogawaconan:
|
|
4 # - `/usr/bin/env bash`
|
|
5 # Source: http://habilis.net/cronic/
|
|
6 #
|
679
|
7 # Cronic v3 - cron job report wrapper
|
|
8 # Copyright 2007-2016 Chuck Houpt. No rights reserved, whatsoever.
|
492
|
9 # Public Domain CC0: http://creativecommons.org/publicdomain/zero/1.0/
|
|
10
|
|
11 set -eu
|
|
12
|
679
|
13 TMP=$(mktemp -d)
|
|
14 OUT=$TMP/cronic.out
|
|
15 ERR=$TMP/cronic.err
|
|
16 TRACE=$TMP/cronic.trace
|
492
|
17
|
|
18 set +e
|
|
19 "$@" >$OUT 2>$TRACE
|
|
20 RESULT=$?
|
|
21 set -e
|
|
22
|
|
23 PATTERN="^${PS4:0:1}\\+${PS4:1}"
|
|
24 if grep -aq "$PATTERN" $TRACE
|
|
25 then
|
|
26 ! grep -av "$PATTERN" $TRACE > $ERR
|
|
27 else
|
|
28 ERR=$TRACE
|
|
29 fi
|
|
30
|
|
31 if [ $RESULT -ne 0 -o -s "$ERR" ]
|
|
32 then
|
|
33 echo "Cronic detected failure or error output for the command:"
|
|
34 echo "$@"
|
|
35 echo
|
|
36 echo "RESULT CODE: $RESULT"
|
|
37 echo
|
|
38 echo "ERROR OUTPUT:"
|
|
39 cat "$ERR"
|
|
40 echo
|
|
41 echo "STANDARD OUTPUT:"
|
|
42 cat "$OUT"
|
|
43 if [ $TRACE != $ERR ]
|
|
44 then
|
|
45 echo
|
|
46 echo "TRACE-ERROR OUTPUT:"
|
|
47 cat "$TRACE"
|
|
48 fi
|
|
49 fi
|
|
50
|
679
|
51 rm -rf "$TMP"
|