1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #!/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
- mail -s "Your Job is Complete" -a ${OUTPUT_FILE} "${ADDRESS}" < ${MESSAGE_FILE}
- rm ${MESSAGE_FILE}
- rm ${OUTPUT_FILE}
- rm ${TIME_FILE}
|