#  cut off when large than 5 hours
#
timelimit=300
count=50000
currentway=`pwd`

while [ $count -gt 0 ]
do

let count=count-1
sleep 120
ps x |grep $currentway|grep "g03" |cut -c0-27>_o_check
if test -s _o_check
then
	gpid=`awk '{printf("%s\n",$1);}'<_o_check`
	gtime=`awk '{printf("%s\n",$4);}'<_o_check|cut -d: -f1`
	if [ $gtime -gt $timelimit ]
	then
		kill $gpid
		rm G*$gpid*
	fi
else	
	count2=60
	while [ $count2 -gt 0 ]
	do
	let count2=count2-1
	sleep 1
	ps x |grep $currentway|grep "g03" >_o_check
	if test -s _o_check
	then
	count2=0
	fi
	done
	
	if test ! -s _o_check
	then
	count=0
	fi
fi


done
rm _o_check
#
