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

时间: 2024-07-30 02:46:42

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

hadoop中的hive查询cdn访问日志指定时间段内url访问次数最多的前10位(结合python语言)

hadoop环境描述: master节点:node1 slave节点:node2,node3,node4 远端服务器(python连接hive):node29 需求:通过hive查询到cdn日志中指定时间段内url访问次数最多的前10个url ps:用pig查询可以查询文章: http://shineforever.blog.51cto.com/1429204/1571124 说明:python操作远程操作需要使用Thrift接口: hive源码包下面自带Thrift插件: [[email pr

python3.7脚本---遍历指定目录内所有文件

#!/usr/bin/python import os import re def getFile(path): fList = os.listdir(path) #将指定目录内的文件以列表格式输出 os.chdir(path) docuPath = os.getcwd() #获取根路径 fileList = [] for f in fList: #对目录内的文件进行遍历 if os.path.isdir(f): #判断文件类型是否为目录 getFile(f) #若是目录,递归运行此函数,继续进

使用WatchService监控指定目录内的文件的改动

package coin; import java.io.IOException; import java.nio.file.FileSystems; import java.nio.file.Path; import java.nio.file.StandardWatchEventKinds; import java.nio.file.WatchEvent; import java.nio.file.WatchKey; import java.nio.file.WatchService; /*

Linux查找指定目录最新修改文件的命令

1. 查找30分钟内最新修改过的文件 find ./ -mmin -30 -type f | head -1 2. 查找30分钟内最早修改过的文件 find ./ -mmin -30 -type f | tail -1 3. 查找24小时内最新修改过的文件 find ./ -mtime 0 -type f | head -1 4. 查找48小时~24小时内最新修改过的文件 find ./ -mtime 1 -type f | head -1 5. 查找最新三天修改过的最新文件 find ./ -

在linux服务器下日志提取的python脚本(实现输入开始时间和结束时间打包该时间段内的文件)

1.需求:近期在提取linux服务器下的日志文件时总是需要人工去找某个时间段内的日志文件,很是枯燥乏味,于是乎,我就想着用python结合linux指令来写一个日志提取的脚本,于是就有了以下脚本文件: 2.代码:getlogzip.py 1 import time,sys,os 2 3 filename1 = time.strftime('%m%d',time.localtime(time.time())) 4 filename2 = "log" 5 servername = inpu

查找某一时间段内的文件

find /usr -type f \( -newermt '15:50' -a -not -newermt '15:55' \) 原文地址:https://www.cnblogs.com/zl1991/p/12421576.html

查找指定目录下的文件?.xml

pre{ line-height:1; color:#9f1d66; background-color:#cfe4e4; font-size:16px;}.sysFunc{color:#5d57ff;font-style:italic;font-weight:bold;} .selfFuc{color:#8e0ed3;} .bool{color:#008000;} .condition{color:#008000;font-weight:bold;} .key{color:#440080;} .

python查找指定目录下所有文件,以及改文件名的方法

一: os.listdir(path) 把path目录下的所有文件保存在列表中: >>> import os>>> import re>>> path = "/home/popt/fiile">>> print (os.listdir(path))['Temp.conf', 'del2.py', 'ha.conf.bak', 'ha.conf', 'del.py', 'rename.py']>>>

python 查找指定内容的txt文件

程序设计思路:1. 利用os.walk()找出所有的文件;2.利用正则找到指定后缀的文件:3.找到需要的txt文件后,通过open().readlines()读取文件中每行数据;4.读取后,保存正则匹配到数据的文件:5.你懂的. #!/usr/bin/env python #coding:utf8 import os import re regtxt = r'.+?\.txt' #扫描对象为txt文件. regcontent = r'what is your name' #列出内容含有'what