Hi, I just wanted to share a small script I hacked to give me some live estimates during database backup. I run it as a subprocess while the database backup is running in foreground in my daily scripts.
Feel free to optimize it... :) -bash-2.05b# cat tsm_vault -----8<----- [...] ( while [[ `${LOGIN} q pro|grep Data|wc -l` -eq 1 ]]; do /home/tsm/bin/dbbstatus.sh; sleep 60; done ) ${LOGIN} backup db devclass=${DEVCLASS} type=full volume=${DBVOLUME} wait=yes | grep AN [...] -----8<----- -bash-2.05b# cat dbbstatus.sh -----8<----- #!/bin/ksh # get total and done pages and calculate percentage done t=`q pro|grep "Database Backup"|awk '{print $9}'` d=`q pro|grep "Database Backup"|awk '{print $6}'` pct=`echo 100*($d/$t)|bc -l` # get startup time and convert to secs sta=`q q actlog begint=-5 msgno=0984 s=DATABASE|tail -1|awk '{print $2}'` hs=$(expr "$sta" : "\(..\):..:..") ms=$(expr "$sta" : "..:\(..\):..") ss=$(expr "$sta" : "..:..:\(..\)") stsecs=$(echo "$hs*3600+$ms*60+$ss" | bc) # get current time and convert to secs now=`date +%T` hn=$(expr "$now" : "\(..\):..:..") mn=$(expr "$now" : "..:\(..\):..") sn=$(expr "$now" : "..:..:\(..\)") # calculate elapsed seconds and convert to hh:mm:ss elasecs=$(echo "$hn*3600+$mn*60+$sn-($hs*3600+$ms*60+$ss)" | bc) # if elapsed time under zero, add a day if [ "$elasecs" -lt 0 ] ; then ((elasecs=elasecs+86400)) fi hl=$(expr $elasecs / 3600) ml=$(expr \( $elasecs - $hl \* 3600 \) / 60) sl=$(expr $elasecs - $hl \* 3600 - $ml \* 60) ela="$hl:$ml:$sl" # estimate total time to completion and convert to hh:mm:ss estsecs=$(echo "$elasecs*100/$pct" | bc) he=$(expr $estsecs / 3600) me=$(expr \( $estsecs - $he \* 3600 \) / 60) se=$(expr $estsecs - $he \* 3600 - $me \* 60) est="$he:$me:$se" # estimate eta and convert to hh:mm:ss etasecs=$(echo "$stsecs + $estsecs" | bc) ha=$(expr $etasecs / 3600) ma=$(expr \( $etasecs - $ha \* 3600 \) / 60) sa=$(expr $etasecs - $ha \* 3600 - $ma \* 60) eta="$ha:$ma:$sa" # output results echo "dbb started: $sta, now: $now, elapsed: $ela, estimated: $est, eta: $eta, done: $pct" -----8<----- Martin