shell脚本连接ftp推送文件夹_Linux下Shell脚本实现FTP自动上传和下载文件

自动上传文件

1、十分钟内/home/scripts/up变动的文件内容统一上传/home/ftp1/up下脚本#!/bin/sh

filename=`find /home/scripts/up -type f -mmin -10|awk -F / {print $NF}`

for i in $filename;

do

ftp -v -n xx.xx.xx.A<

user ftp1 123456

binary

cd up

lcd /home/scripts/up

prompt

put $i

bye

EOF

echo "commit to ftp successfully"

done

2、二十分钟内/home/scripts/up下变动的文件上传/home/ftp1/up下对应的文件夹下脚本

路径:find /home/scripts/up -type f -mmin -120 -exec dirname {} \;#!/bin/sh

#切换到上传根目录下

cd /home/scripts/up

file=`find ./ -type f -mmin -20`

�6�7

for i in $file;

do

�6�7

#获取文件名

filename=`find $i|awk -F / {print $NF}`

#获取路径名

dirname=`find $i -exec dirname {} \;`

�6�7

�6�7

ftp -v -n xx.xx.xx.A<

user ftp1 123456

binary

cd up

cd $dirname

pwd

lcd $dirname

prompt

pwd

put $filename

bye

EOF

�6�7

echo "commit to ftp successfully"

done

注意:sftp可以通过put -r 递归创建目录,ftp不行

上面是之前分开写的几个脚本,这个还是看需求吧,整体难度不大,大家可以自己测试下。后面会分享更多关于devops和DBA方面内容,感兴趣的朋友可以关注下!!

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值