런닝타임 구하는 쉘 스크립트
2010. 7. 8. 11:55ㆍ99. 정리전 - IT/13. Unix 얇팍지식
#!/bin/sh
time1_total=`date +%s.%N`
echo "####################################"
echo "## 01. ㅌㅌㅌ ##"
echo "####################################"
time1=`date +%s.%N`
echo "## START : "`date +'%Y%m%d%H%M%S'`
/쉘프로그램.sh
echo "## END : "`date +'%Y%m%d%H%M%S'`
time2=`date +%s.%N`
diff=`echo "$time2 - $time1" | bc`
htime=`echo "$diff/3600" | bc`
mtime=`echo "($diff/60) - ($diff * 60)" | bc`
stime=`echo "$diff - (($diff/60) * 60)" | bc`
echo "## RUNNING TIME : ${htime}시간 ${mtime}분 ${stime}초"
echo "####################################"
echo "## 02. ㅋㅋㅋ ##"
echo "####################################"
time1=`date +%s.%N`
echo "## START : "`date +'%Y%m%d%H%M%S'`
/쉘프로그램.sh
echo "## END : "`date +'%Y%m%d%H%M%S'`
time2=`date +%s.%N`
diff=`echo "$time2 - $time1" | bc`
htime=`echo "$diff/3600" | bc`
mtime=`echo "($diff/60) - ($diff * 60)" | bc`
stime=`echo "$diff - (($diff/60) * 60)" | bc`
echo "## RUNNING TIME : ${htime}시간 ${mtime}분 ${stime}초"
echo "####################################"
echo "## TOTAL RUNNING TIME ##"
echo "####################################"
echo "## START : "$time1_total
echo "## END : "$time2_total
time2_total=`date +%s.%N`
diff=`echo "$time2_total - $time1_total" | bc`
htime=`echo "$diff/3600" | bc`
mtime=`echo "($diff/60) - ($diff * 60)" | bc`
stime=`echo "$diff - (($diff/60) * 60)" | bc`
echo "## RUNNING TIME : ${htime}시간 ${mtime}분 ${stime}초"
exit 0
time1_total=`date +%s.%N`
echo "####################################"
echo "## 01. ㅌㅌㅌ ##"
echo "####################################"
time1=`date +%s.%N`
echo "## START : "`date +'%Y%m%d%H%M%S'`
/쉘프로그램.sh
echo "## END : "`date +'%Y%m%d%H%M%S'`
time2=`date +%s.%N`
diff=`echo "$time2 - $time1" | bc`
htime=`echo "$diff/3600" | bc`
mtime=`echo "($diff/60) - ($diff * 60)" | bc`
stime=`echo "$diff - (($diff/60) * 60)" | bc`
echo "## RUNNING TIME : ${htime}시간 ${mtime}분 ${stime}초"
echo "####################################"
echo "## 02. ㅋㅋㅋ ##"
echo "####################################"
time1=`date +%s.%N`
echo "## START : "`date +'%Y%m%d%H%M%S'`
/쉘프로그램.sh
echo "## END : "`date +'%Y%m%d%H%M%S'`
time2=`date +%s.%N`
diff=`echo "$time2 - $time1" | bc`
htime=`echo "$diff/3600" | bc`
mtime=`echo "($diff/60) - ($diff * 60)" | bc`
stime=`echo "$diff - (($diff/60) * 60)" | bc`
echo "## RUNNING TIME : ${htime}시간 ${mtime}분 ${stime}초"
echo "####################################"
echo "## TOTAL RUNNING TIME ##"
echo "####################################"
echo "## START : "$time1_total
echo "## END : "$time2_total
time2_total=`date +%s.%N`
diff=`echo "$time2_total - $time1_total" | bc`
htime=`echo "$diff/3600" | bc`
mtime=`echo "($diff/60) - ($diff * 60)" | bc`
stime=`echo "$diff - (($diff/60) * 60)" | bc`
echo "## RUNNING TIME : ${htime}시간 ${mtime}분 ${stime}초"
exit 0