Shell拷贝本地文件到远程主机

#!/bin/sh
timelimit=2
if [ $# -ne 0 ] ; then
 timelimit=$1
fi
startdate=`date +%m%d`
for((i=1;i<=$timelimit;i++));
do
  count=`expr  $i \* 24`
  result=`printf %03d $count`
  
  logdate=`date +%F`
  logtime=`date +%T`
  file="/disk2/diamond/update/gwcity/gc${startdate}20.$result"
  if [ -a file ] ; then
    echo "$logdate $logtime warn $file is not exists" >> /root/taskmonitor/log.log
  else
    scpStr="scp $file [email protected]:/data/gwcity/"
    $scpStr
    if [ $? -eq 0 ] ; then
      echo "$logdate $logtime debug $scpStr is successfully" >> /root/taskmonitor/log.log
    else
      echo "$logdate $logtime error $scpStr is failure" >> /root/taskmonitor/log.log
    fi
  fi
done
 

猜你喜欢

转载自voole.iteye.com/blog/1138269