12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- #!/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 <<EOF > ${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 <<EOF >> ${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}
|