简体   繁体   English

通过 cron 文件从 FTP 服务器访问和传输文件到我的 ftp 服务器

[英]Acessing and transferring files from a FTP server to my ftp server through cron file

I have a FTP Server that uses Cron to automate tasks and I would like to use it to access another ftp server, get a file that starts with 26 and have an extension.csv, transfer to my FTP I am running the cron and delete the file on the origin FTP server, every friday of the week. I have a FTP Server that uses Cron to automate tasks and I would like to use it to access another ftp server, get a file that starts with 26 and have an extension.csv, transfer to my FTP I am running the cron and delete the每周的每个星期五在源 FTP 服务器上的文件。 Can somebody help me with the script code?有人可以帮我编写脚本代码吗?

What I have right now is this:我现在拥有的是这样的:

#!/bin/bash -x

filename="dir/*.csv"
hostname="files.test"
username="testuser"
password="testpassword"

ftp -in $hostname <<EOF
quote USER $username
quote PASS $password

binary
get $filename
quit
EOF

Please, help请帮忙

#!/bin/bash
USER=user
PASS=password
URL=myIP
PLACE=tmp
#
ftp -v -n > /tmp/xftpb.log <<EOF
        open $URL
        user $USER $PASS
        binary
        cd $PLACE
        mget 26*.csv
        mdel 26*.csv
        quit
EOF

To run every friday, 8:00h, use at crontab:要在每个星期五 8:00 运行,请在 crontab 中使用:

0 8 * * 5     /path/mybash.sh

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

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