如果我使用qstat
,我可以获取当前正在运行的作业列表
host username othername NameTask_JOBXXXX_G1_namesubtask -- 1 1 -- 8783: Q 00:00
host username othername NameTask2_JOBXXXX_G2_namesubtask -- 1 1 -- 8783: C 00:00
到目前为止,我可以使用ksh脚本跟踪状态:
#!/usr/bin/ksh
while sleep 2; do ; echo -n $(mystat | grep JOB | grep -c Q) 'Queued ' ;
echo -n $(mystat | grep JOB | grep -c ': R') 'Running ' ;
echo $(mystat | grep JOB | grep -c ': C') 'Completed ' ;
echo "$(mystat | grep C | tail -n 5 | tr -s ' ' | cut -d ' ' -f 4,11)"
echo
done
在最后5个已完成的工作完成时,每2秒钟给我一个Running,Queud,Complemented的数量。
如何对此进行扩展以计算具有不同' NameTask _'的行数。目前正在运行? 我想得到上一个脚本的结果,但是按NameTask_和G _
分组答案 0 :(得分:0)
似乎是数组的工作
typeset -A jobCnt # Associative array for job counts
typeset -A ntCnt # A. array for NameTask count
typeset -A stCnt # A. array for namesubtask count
typeset -a cjList # Indexed array for Completed job list
integer ci=0
while read host uName oName tName v w x y z stat statTime
do
((jobCnt[${stat}]++)) # Count of (current) jobs by status
if [[ ${stat} == C ]] # Completed task (time) ordered
then
cjList[$((ci++))]=${statTime}
fi
((ntCnt[${tName%%_*}]++)) # NameTask count
((stCnt[${tName##*_}]++)) # namesubtask count
done
for st in ${!jobCnt[@]} # Over 'st'atus in jobCnt array
do
echo "Number ${st} jobs: ${jobCnt[${st}]}"
done
echo "Last 5 Completed jobs:"
if (( ${#cjList[@]} <= 5 ))
then
integer istart=0 # All C jobs in array
else
((istart = ${#cjList[@]} - 5)) # Last 5 jobs in array
fi
for ((i=${istart} ; i<${#cjList[@]} ; i++))
do
echo ${cjList[${i}]}
done
echo "Job counts by NameTask: "
for n in ${!ntCnt[@]}
do
echo "${n} ${ntCnt[${n}]}"
done
echo "Job counts by NameSubTask: "
for s in ${!stCnt[@]}
do
echo "${s} ${stCnt[${s}]}"
done