我想将文件从远程服务器复制到本地服务器.问题是:我只想复制昨天的文件.远程服务器正在写日志文件,在23:59,logrotation将其压缩为文件[name] _ [date] .log.gz.早上6点,本地服务器上的cronjob需要复制先前从远程服务器创建的文件.有谁知道如何做到这一点?
问候,亚历克斯
Osc*_*erd 10
你可以使用这样的脚本
for i in `find /interface/outbound/Web -type f -ctime -1`
do
scp $i user@$destination_server:/destination_directory/
done
Run Code Online (Sandbox Code Playgroud)
特别是该命令可以找到以下功能,例如:
find . -ctime -1 # which are created less than 1 day ago from currrent folder.
find . -ctime +2 # finds files which are created older than 2 days from currrent folder.
Run Code Online (Sandbox Code Playgroud)
ctime创作时间在哪里.也可以这样使用修改时间mtime:
find . -mtime 0 # find files modified between now and 1 day ago
find . -mtime -1 # find files modified less than 1 day ago
find . -mtime 1 # find files modified between 24 and 48 hours ago
find . -mtime +1 # find files modified more than 48 hours ago
Run Code Online (Sandbox Code Playgroud)
更多关于男人的信息
编辑:
要从远程到本地具有相同的行为,您可以使用以下内容:
latest_file=`ssh user@destination_server find /pathtoDir -type f -ctime -1`
/usr/bin/scp user@destination_server:$latest_file /local_dir
echo SCP Completed.
Run Code Online (Sandbox Code Playgroud)
此刻我还没有Unix环境来进行一些测试.
| 归档时间: |
|
| 查看次数: |
12959 次 |
| 最近记录: |