Moving the files based on count and time.

Hi,

I have a requirement ,let us say 1000 files needs to be transferred in an hour from one path to another path and if the files (1000 files) are transferred within an hour ( say 40 mins), then the process should remain idle for the remaining time ( 20 mins).

Something like :

while [ `find $path1 -type file` -gt 0 ]
do
  beforeS=$(date +"%S")
  beforeM=$(date +"%M")
  beforeH=$(date +"%H")
  before=`expr $beforeS + beforeM * 60 + beforeH * 3600`
  find $path1 -type file | head -1000 | while read file
  do
     mv $file $path2
  done
  afterS=$(date +"%S")
  afterM=$(date +"%M")
  afterH=$(date +"%H")
  after=`expr $afterS + afterM * 60 + afterH * 3600`
  diff=$(($after-$before))
  remaining=`expr 3600 - $diff` #remaining in seconds
  [ $remaining -gt 0 ] && sleep $remaining
done

not tested though, and also wouldn't work if say the script is launched around midnight.. need to add the days, month and years in the calculation.
good luck.

Or:

sleep 3600&
perform-copy-operations
wait

much smarter indeed
shame on me :stuck_out_tongue: