Shell Script to Repeat the Execution of Command / Job Based on Time Interval Periodically


Suppose if you are copying some huge files from server to another server and you wanted to see the progress in size, number you can use these scripts. These scripts will run periodically according to the sleep commands.

Using yes Command

To find the size of the files copied.
yes "date;ls -ltr * |awk '{ sum+=\$5 } END {print \"Bytes InGb:\" sum/1024/1024/1024}'; sleep 60" | sh
To find the number of files copied.
yes "date;ls -l|wc -l; sleep 60" | sh

Using while loop
while true
do
date
ls -ltr * |awk '{ sum+=$5 } END {print "Bytes In Gb:" sum/1024/1024/1024}'
ls |wc -l
sleep 60
done

Examples:
while true
> do
> date
ls -ltr * |awk '{ sum+=$5 } END {print "Bytes In Gb:" sum/1024/1024/1024}'
ls |wc -l
> sleep 60
> done
Wed May 22 09:10:12 CEST 2013
Bytes In Gb:0.089733
9

DBA Tips Data Pump Reference

0 comments:

Post a Comment

 

dba topics. Copyright 2011-16 All Rights Reserved | Site Map | Contact | Disclaimer | Google