#!/bin/bashlocal_dir=/root/testremote_host="0.0.0.0"remote_dir=/root/testcompleted_dir=/root/completedalias rm="rm"cd $local_direcho "STARTING TRANSFER FOR UGC-INTERNAL `date`"if [ -f $local_dir/.running ]thenecho "Another processing is running, will exit"exitelsetouch $local_dir/.runningfi# copy the file from the UGC-INTERNAL DMZ server to local boxfor i in `ssh root@$remote_host "find $remote_dir -type f -print -exec ls {} \;" `; docd $local_dirscp root@$remote_host:${i} $local_direcho "finished transferring files ${i} from UGC-INTERNAL DMZ server to localhost"done# remove files from the UGC-INTERNAL completed dir for t in `ssh root@$remote_host "find $remote_dir -type f -print -exec ls {} \;"`; doecho " Moving files ${t} to ${completed_dir}"ssh root@$remote_host "mv ${t} $completed_dir"donefor r in `ssh root@$remote_host "find $completed_dir -print -mtime +30 -exec ls {} \;"`; doecho "Removing files ${r} from UGC-INTERNAL DMZ server"ssh root@$remote_host "rm ${r}"donerm $local_dir/.runningecho "COMPLETED `date`"exit