shell查找指定时间段内的文件

#!/bin/bash
#20170905 输入参数格式
echo "显示"$1"的备份文件"
date_0=$1
date_1=`expr $date_0 + 1`
date_2=`expr $date_0 + 2`

#定义时间段

touch -d $date_0 /tmp/tm-0.file #开始时间
touch -d $date_1 /tmp/tm-1.file #结束时间1
touch -d $date_2 /tmp/tm-2.file #结束时间2

datadir=/data/backup/oracle/

#数组

host=(hostname1 hostname2 hostname3 hostname4)

#遍历数组

for i in ${host[@]};do
cd $datadir
echo "同步"${i}"数据."

#查找指定时间段的文件,使用rsync传输


find ${i} -newer /tmp/tm-0.file ! -newer /tmp/tm-1.file -type f -exec rsync -avzRF --exclude="*.dmp" {} 192.168.8.64::backup_ora ;
find ${i} -newer /tmp/tm-0.file ! -newer /tmp/tm-2.file -iname "arc*" -type f -exec rsync -avzRF --exclude="*.dmp" {} 192.168.8.64::backup_ora ;
done

原文地址:https://www.cnblogs.com/janehoo/p/7612155.html