20 lines
362 B
Bash
Executable File
20 lines
362 B
Bash
Executable File
#!/bin/bash
|
|
|
|
SCRIPT=$1
|
|
|
|
shift
|
|
|
|
$SCRIPT "$@" 2>&1 | tee /tmp/backup.log
|
|
ERR=$?
|
|
|
|
OUTPUT=$(cat /tmp/backup.log)
|
|
rm /tmp/backup.log
|
|
|
|
if [ $ERR -ne 0 ]; then
|
|
MAILTO=$(cat "$HOME/.admin_mail")
|
|
echo "Sending error mail"
|
|
echo -e "An error occured during the execution of $SCRIPT.\n\n$OUTPUT" | mailx -s "$(hostname) $SCRIPT failure" "$MAILTO"
|
|
echo "Sent"
|
|
exit 1
|
|
fi
|