我需要在bash/python
中编写一个脚本到scp
最新的文件,它到达给定的文件夹。那个是我不断地把文件放入一个文件夹,比如说(/home/ram/Khopo/
),我需要将它scp到xxx@192.168.21.xxx
的/home/xxx/khopo/
。在
我在谷歌上搜索得到了这个结果
file_to_copy=`ssh username@hostname 'ls -1r | head -1'`
echo copying $file_to_copy ...
scp username@hostname:$file_to_copy /local/path
但我想知道是否有可能这样做:它只在新文件夹到达源时运行(/home/ram/Khopo/
),并等待文件到达文件夹并在到达时立即执行
我会尝试同步远程目录。这会给你带来美好的前景,如何做到:
同步:
https://askubuntu.com/a/105860
https://www.atlantic.net/hipaa-compliant-cloud-storage/how-to-use-rsync-copy-sync-files-servers/
或其他同步工具: https://en.wikipedia.org/wiki/Comparison_of_file_synchronization_software
{cdbashan>在下面的例子中,你可以使用
然后您最好将此脚本置于后台运行,例如:
^{pr2}$对于
sshpass
您可以使用以下方式在ubunut/debian中安装它:相关问题 更多 >
编程相关推荐