Source

fogbow / bin / email_when_run.sh

Full commit
#!/bin/bash -u

#Subject: 	[dicta] The script to email yourself when your TACC job is ready
#Date: 	Thu, 1 Sep 2011 14:29:54 -0500
#From: 	Hohyon Ryu 
#
#Here's the script to email yourself when your TACC job is ready.
#
# Example use:
#
# cat qsub.sh
#qstat
#echo "Deleting .hadoop2 logs"
#rm -rf ~/.hadoop2/logs
#rm Hadoop*
#echo "Submiting Job.."
#qsub job.hadoop.new
#email_when_run.sh &

# input argument or replace with hard-coded
if [ -z $EMAIL ] 
then
    EMAIL=$1
fi

AVAIL=`qstat | grep $USER | awk '{print $5}'`;

echo "Waiting until hadoop runs...";
while [ $AVAIL == "qw" ]; do
       AVAIL=`qstat | grep $USER | awk '{print $5}'`;
       sleep 10;
done

echo "It is running now!"
echo "$AVAIL: `date` ";

mail_cont="go ahead and do it!"
mail -s "TACC Hadoop job is Running!" "$EMAIL" < Hadoop-test.out