#!/bin/bash # # Send email when all jobs in a batch are finished. # The script doesn't return until that time. # It's probably best off being backgrounded, unless # the next command is intended to be run after the # completion of all jobs. # address to which to send it emailaddr="batch_users_email_name@ntmm.org" # time [s] between checks of jobs interval=180 # try to change to the batch's base directory basedir="$(dirname "$(realpath "$0" )" )" if ! cd "$basedir" then echo "Problem trying to change directory to " echo "$basedir/" echo "Exiting." exit 3 fi # loop until `RUNNING' is NOT found in the host status until ! ./report_job_status hosts | grep -q RUNNING do sleep $interval done # send the contents of the hosts and durations, by email ( echo " " ./report_job_status hosts echo " " ./report_job_status findur echo " " ) | mail -s "batch: \"`basename \"\`realpath "$basedir"\`\"`\" is finished" $emailaddr