From fcae1092c3665129be1fa8578af19ddbd6cbc4c6 Mon Sep 17 00:00:00 2001 From: jiang548 Date: Wed, 4 May 2022 00:38:36 -0400 Subject: [PATCH] add email notification --- script/file_manage.sh | 17 ++++++++++++++++- script/network/bts1gensub.sh | 2 ++ script/network/bts2gensub.sh | 2 ++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/script/file_manage.sh b/script/file_manage.sh index d43320e..e00382b 100644 --- a/script/file_manage.sh +++ b/script/file_manage.sh @@ -86,4 +86,19 @@ fi } -export -f file_purge dir_check file_check numeric_check +# input: email, job name, status +email_note(){ +email=$1 +job_name=$2 +status=$3 + +if [[ $email != "*@*" ]] +then + if [[ $(which mail) != "" ]] + then + echo -e "Your $job_name using SIGNET is $status \n" | mail -s "SIGNET NOTIFICATION" $email + fi +fi +} + +export -f file_purge dir_check file_check numeric_check email_note diff --git a/script/network/bts1gensub.sh b/script/network/bts1gensub.sh index d8ddf0d..4b6512c 100755 --- a/script/network/bts1gensub.sh +++ b/script/network/bts1gensub.sh @@ -104,8 +104,10 @@ nresult=$(find ypre* | wc -l ) if [ $nresult -eq $NJOBS ] then echo -e "All the jobs are finished !!\n" +email_note $email "Stage 1" "Completed !!!" else echo -e "Please notice that some of the jobs are unfinished. Program will stop and please try to find the problem. \n" +email_note $email "Stage 1" "Stopped ..." grep -Eo '[0-9]+$' submit1_log | xargs scancel kill -10 $job_id exit -1 diff --git a/script/network/bts2gensub.sh b/script/network/bts2gensub.sh index 7af519e..018718b 100755 --- a/script/network/bts2gensub.sh +++ b/script/network/bts2gensub.sh @@ -108,8 +108,10 @@ nresult=$(find Adj* | wc -l ) if [ $nresult -eq $NJOBS ] then echo -e "All the jobs are finished !!\n" +email_note $email "Stage 2" "Completed !!!" else echo -e "Please notice that some of the jobs are unfinished. Program will stop and please try to find the problem. \n" +email_note $email "Stage 2" "Stopped ..." grep -Eo '[0-9]+$' submit2_log | xargs scancel kill -10 $job_id exit -1