Friday, 24 January 2014

How to check duration of copying a file ?

Q. How to check duration of copying a file  ?

Ans...

#!/bin/bash
    start_time_hour=`expr $(date '+%H') \* 3600`
    start_time_minute=`expr $(date '+%M') \* 60`  
    start_time_second=`expr $(date '+%S')`
    start_time=`expr $start_time_hour + $start_time_minute + $start_time_second`
    echo $start_time
while true
do  
    first_value=$(du -s /home/ibmi | cut -f1)
    echo "$(date '+TIME:%H:%M:%S') $(du -sh /home/ibmi/)" | tee -a test.watch
    sleep 5
    second_value=$(du -s /home/ibmi | cut -f1)
    if [ $first_value -eq $second_value ]
    then
        echo "Copy Completed... Exiting...."
    end_time_hour=`expr $(date '+%H') \* 3600`
        end_time_minute=`expr $(date '+%M') \* 60`  
        end_time_second=`expr $(date '+%S')`
        end_time=`expr $end_time_hour + $end_time_minute + $end_time_second`
        duration=`expr $end_time - $start_time`
        echo "Duaration taken to Copy the file is... $duration seconds"      
        break
    fi      
done

No comments:

Prasanta Kumar Behera. Mob- 8147470101