FTP自动上传文件和自动下载文件脚本

1、自动从ftp服务器下载当天指定文件脚本:bash

#!/bin/bash 
ftp -nv 1.2.3.4 <<!FTPRUN
user bossftp 123456 
prompt 
bin 
cd abc 
lcd /data/abc/
get Afile$(date +%Y%m%d).txt
get Vfile$(date +%Y%m%d).txt
bye 
!FTPRUN

crontab脚本服务器

#每个月21日,25日9点执行
0 9 21,25 * * /data/getfile.sh >>/var/log/getftpfile.log 2>&1

2、自动上传当天文件到ftp服务器脚本:日志

#!/bin/bash 
ftp -nv 1.2.3.4 <<!FTPRUN
user bossftp 123456 
prompt 
bin 
cd upfile
lcd /data/upfile
put H-file_$(date +%Y%m%d).txt
put H-state_$(date +%Y%m%d).txt
bye 
!FTPRUN

crontab脚本code

#每个月1日2点执行putfile脚本,并记录日志
0 2 1 * * /data/upfile/putfile.sh >>/var/log/putfile.log 2>&1