|
@@ -1,17 +1,43 @@
|
|
#!/usr/bin/env bash
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
+ADDRESS=$1
|
|
|
|
+shift
|
|
|
|
+
|
|
JOB=$1
|
|
JOB=$1
|
|
-COMMANDFILE=$2
|
|
|
|
-ADDRESS=$3
|
|
|
|
|
|
+shift
|
|
|
|
+
|
|
|
|
+START_TIME=$(date)
|
|
|
|
+OUTPUT_FILE=$(mktemp)
|
|
|
|
+TIME_FILE=$(mktemp)
|
|
|
|
+
|
|
|
|
+env time -o ${TIME_FILE} /bin/sh $@ 2>&1 | tee ${OUTPUT_FILE}
|
|
|
|
|
|
-mkdir -p "~/jobs/${JOB}"
|
|
|
|
|
|
+END_TIME=$(date)
|
|
|
|
|
|
-/bin/sh "$COMMANDFILE" | tee "~/jobs/${JOB}/output"
|
|
|
|
|
|
+MESSAGE_FILE=$(mktemp)
|
|
|
|
|
|
-mail -s "Your Job is Complete" -a "~/jobs/${JOB}/output" "${ADDRESS}" <<EOF
|
|
|
|
|
|
+cat <<EOF > ${MESSAGE_FILE}
|
|
The output of the command file is attached.
|
|
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}
|
|
JOB=${JOB}
|
|
-COMMANDFILE=${COMMANDFILE}
|
|
|
|
|
|
+COMMAND=$@
|
|
ADDRESS=${ADDRESS}
|
|
ADDRESS=${ADDRESS}
|
|
EOF
|
|
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}
|