#!/usr/bin/env bash ADDRESS=$1 shift JOB=$1 shift START_TIME=$(date) OUTPUT_FILE=$(mktemp) TIME_FILE=$(mktemp) env time -o ${TIME_FILE} /bin/sh $@ 2>&1 | tee ${OUTPUT_FILE} END_TIME=$(date) MESSAGE_FILE=$(mktemp) cat < ${MESSAGE_FILE} The output of the command file is attached. Start time: ${START_TIME} End time: ${END_TIME} Process Time Statistics: EOF cat ${TIME_FILE} >> ${MESSAGE_FILE} cat <> ${MESSAGE_FILE} JOB=${JOB} COMMAND=$@ ADDRESS=${ADDRESS} EOF cat ${MESSAGE_FILE} echo mail -s "Your Job is Complete" -a ${OUTPUT_FILE} "${ADDRESS}" < ${MESSAGE_FILE} rm ${MESSAGE_FILE} rm ${OUTPUT_FILE} rm ${TIME_FILE}