qtail

#!/bin/bash
#
#
usage_exit(){
  echo "usage: qtail [-f] [-e] <jobid>" 1>&2
  exit 1
}
##---------------------------------------------------#
while getopts :fe OPT
do
  case $OPT in
     f) f=1
        ;;
     e) e=1
        ;;
     \?) usage_exit
        ;;
  esac
done
shift $((OPTIND -1))
 
id=${1%%.*}
expr "$id" + 1 > /dev/null 2>&1
if [ $? -gt 1 ]; then
     usage_exit
fi
##---------------------------------------------------#
host=$(qstat -n -1 $id | tail -n1 | awk '{print $12}' | tr -s '+', '\n' | sort -u)
# PBSProの場合
#host=$(qstat -n -1 $id | tail -n1 | awk '{print $12}' | tr -s '+', '\n' | cut -f1 -d'/' | sort -u)
 
for i in $host
do
if [ $e ]; then
  m=$(rsh $i ls /var/lib/torque/spool/$id.*.ER)
 #m=$(rsh $i ls /var/lib/pbs/spool/$id.*.ER)
else
  m=$(rsh $i ls /var/lib/torque/spool/$id.*.OU)
  #m=$(rsh $i ls /var/lib/pbs/spool/$id.*.OU)
fi
if [ $m ]; then
    if [ $f ]; then
      rsh $i tail -f $m
      exit
    else
      rsh $i tail $m
      exit
    fi
fi
done

qhead

#!/bin/bash
 
usage_exit(){
  echo "usage: qhead [-n num] [-e] <jobid>" 1>&2
  exit 1
}
##---------------------------------------------------#
while getopts :en: OPT
do
  case $OPT in
     e) e=1
        ;;
     n) num=$OPTARG
        ;;
     \?) usage_exit
        ;;
  esac
done
shift $((OPTIND -1))
 
id=${1%%.*}
expr "$id" + 1 > /dev/null 2>&1
if [ $? -gt 1 ]; then
     usage_exit
fi
if [ $num ]; then
  expr "$num" + 1 > /dev/null 2>&1
  if [ $? -gt 1 ];then
     usage_exit
  fi
fi
 
##---------------------------------------------------#
host=$(qstat -n -1 $id | tail -n1 | awk '{print $12}' | tr -s '+', '\n' | sort -u)
# PBSProの場合
#host=$(qstat -n -1 $id | tail -n1 | awk '{print $12}' | tr -s '+', '\n' | cut -f1 -d'/' | sort -u)
for i in $host
do
if [ $e ]; then
   m=$(rsh $i ls /var/lib/torque/spool/$id.*.ER)
   #m=$(rsh $i ls /var/lib/pbs/spool/$id.*.ER)
else
   m=$(rsh $i ls /var/lib/torque/spool/$id.*.OU)
   m=$(rsh $i ls /var/lib/pbs/spool/$id.*.OU)
fi
if [ $m ]; then
    if [ $num ]; then
      rsh $i head -n $num $m
      exit
    else
      rsh $i head $m
      exit
    fi
fi
done

トップ   編集 添付 複製 名前変更     ヘルプ   最終更新のRSS
Last-modified: 2017-11-08 (水) 18:19:01 (39d)