Sunday, 7 July 2013

scp parallel Linux script

Please test before it use:

#!/bin/ksh
cnt=1
RHOST=srv245005
CCMD="ls /db/remote_backup_area"

for BackupFile in 'ssh -q oracle@${RHOST} ${CCMD}'; do
        echo "attempting to copy file: " $BackupFile
       
        #scp -pq $hostname:/db/remote_backup_area/$file /db/local_dump_area &
        (
      echo "starting $file `date`" >/tmp/status/${file}.log
      scp -pq $hostname:/db/remote_backup_area/$file /db/local_dump_area 2>>/tmp/status/${file}.log
      echo "done $file `date`" >>/tmp/status/${file}.log
    ) &
        cnt=$(( $cnt + 1 ))
        if [ cnt -eq 10 ] then
           wait
           cnt=1
        fi

done
wait
exit

No comments:

Post a Comment