Skip to content

Instantly share code, notes, and snippets.

@brimston3
Created July 15, 2014 11:59
Show Gist options
  • Save brimston3/53c90e014fac628e627d to your computer and use it in GitHub Desktop.
Save brimston3/53c90e014fac628e627d to your computer and use it in GitHub Desktop.
multi-environment kill-and-hold for autosys... if this script would work for you, you should know on sight. I assume no liability from using parts of this script. {} string expansions need bash. Script tested in bash 4.2. You may need to re-alias jr and se before executing.
######## DO SETUP ########
e=accD
pre=UD
jildir=$DATDIR/../jil
for file in "`ls -1 \"$jildir\"`"
do
ostr=`grep delete_box $file | gawk -v s=$pre '{if (NR>1) {exit(0)};gsub(/\\\$S/,s,$2);print $2}'`
echo $ostr
stat=`jr $ostr | egrep '^'$ostr | sed -e 's@.* \([A-Z][A-Z]\) .*@\1@'`
echo $ostr $stat
echo $ostr >> ${e}_${stat}
done
######## DO MASSIVE BREAKAGE ########
for each in `cat {mod{A,B,C,D,E},acc{A,B,C,D}}_{SU,AC,RU}`; do
stat=`jr $each | egrep '^'$each | sed -e 's@.* \([A-Z][A-Z]\) .*@\1@'`
if [[ "$stat" != "OH" ]]; then
if [[ "$stat" = "RU" ]] || [[ "$stat" = "AC" ]]; then
echo "Re-killing $each"
se KILLJOB -j $each
SC=0
while sleep 1
do
stat=`jr $each | egrep '^'$each | sed -e 's@.* \([A-Z][A-Z]\) .*@\1@'`
if [[ "$stat" = "TE" ]]; then
break
fi
SC=$((SC + 1))
if [[ "$SC" -gt 10 ]]; then
echo "Job didn't die after 10 seconds, continuing on hope."
break;
fi
done
fi
if [[ "$stat" != "TE" ]]; then
echo "Potential problem: $each is $stat"
fi
echo "Setting OH: $each"
se JOB_ON_HOLD -j $each
fi
done
######## UNCRY THESE TEARS ########
for each in `cat {mod{A,B,C,D,E},acc{A,B,C,D}}_{SU,AC,RU}`; do
stat=`jr $each | egrep '^'$each | sed -e 's@.* \([A-Z][A-Z]\) .*@\1@'`
if [[ "$stat" = "OH" ]]; then
echo "Unholding $each"
se JOB_OFF_HOLD -j $each
fi
done
@brimston3
Copy link
Author

In my opinion, this script is too short for a copyright notice, but in case anyone does need one, bsdnew. Wrote in about 15 minutes, executed staggered over 5 hrs....

@brimston3
Copy link
Author

gawk can be replaced with nawk, I think; had gawk, used gawk. Have had problems with gsub and solaris awk on occasion.

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