繁体   English   中英

Bash脚本用于scp远程服务器上目录中的最新文件

[英]Bash script to scp newest file in a directory on a remote server

好的,所以我知道如何使用find then cp命令在本地执行此操作,但不知道如何使用scp远程执行相同操作。

所以知道这个:

scp -vp me@server:/target/location/ /destination/dir/.

该目标目录将充满数据库备份,如何告诉它查找最新备份,以及本地scp?

remote_dir=/what/ever
dst=remote-system.host.name.com
scp $dst:`ssh $dst ls -1td $remote_dir/\* | head -1` /tmp/lastmod

在远程端编写一个脚本,使用find查找它然后cat将其发送到stdout,然后运行:

ssh me@server runscript.sh > localcopy

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM