Skip to content

Instantly share code, notes, and snippets.

@MikeDacre
Created March 21, 2015 16:41
Show Gist options
  • Select an option

  • Save MikeDacre/e85b0ccd85807a352120 to your computer and use it in GitHub Desktop.

Select an option

Save MikeDacre/e85b0ccd85807a352120 to your computer and use it in GitHub Desktop.
Watch a submitted qsub job and email the results of qstat -f when complete
#!/bin/bash
if [ $# != 2 ]; then
echo "USAGE: watch_job <submit_script> <email_address>"
exit 1
fi
job=$1
email=$2
while true; do
sleep 1
i=$(qstat -u $USER | grep $job | grep " C ")
if [ $i ]; then
sleep 5
output=$(qstat -u $USER -f)
echo $output | sendmail -s "Job Complete" mike.dacre@gmail.com
exit
fi
done
@MikeDacre
Copy link
Copy Markdown
Author

Run in background:
nohup watch_job <job_no> <your_email> &

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment