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

advertisements

_____________________________________________________________________________________________________________________

The Eucharistic Miracles of the World

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

_____________________________________________________________________________________________________________________

Website Stats

0 comments:

Post a Comment

Labels

Oracle (629) Script (86) General (77) Unix (47) Blog (23) Technology (19) gadget (6) games (6) Business (3) OCI (3) SQL* Loader (3) Datapump (2)
 

acehints.com Copyright 2011-23 All Rights Reserved | Site Map | Contact | Disclaimer