按文件创建日期进行同步

#!/bin/bash

time_now=`ssh -l root 172.17.101.163 "date +%s"`
rooms=`ssh -l root 172.17.101.163 "ls /home/waypal/volume/kms/kms-media"`
for room in $rooms
do
   read -t 5 -p "continue ? [y/n default y]" answer
   answer=${answer:-y}
   echo "you choise:$answer"
   if [ $answer != y ];then
      exit;
   fi

   echo "/home/waypal/volume/kms/kms-media/$room"
   time_lastchanged=`ssh -l root 172.17.101.163 "stat -c %Y /home/waypal/volume/kms/kms-media/$room"`
   time_ago=$[ $time_now - $time_lastchanged ]
   if [ $time_ago -gt 3600 ];then
       #echo "$time_now,$time_lastchanged,$time_ago"
       rsync -av --progress -e ssh root@172.17.101.163:/home/waypal/volume/kms/kms-media/$room  $HOME/waypalers.cn/waypal/shared/resources/records && ssh root@172.17.101.163 "rm -r /home/waypal/volume/kms/kms-media/$room";
   fi
done