此脚本将通过 FTP 发送文件,然后将其删除。但是,有时,文件在传输结束之前被删除,然后接收到一个空文件。
#!/bin/bash
tar czf <sourcefile> --directory=<directory> log
ftp -v -n $1 <<END_OF_SESSION
user <user> <password>
put <sourcefile> <targetfile>
bye
END_OF_SESSION
rm <sourcefile>
什么是同步进程的好方法,以便在发送完成后进行删除?
如下更新所示,有时无法建立连接。
笔记:
在 Lubuntu 16.04 上运行。
随行更新tar
。
失败会话的日志信息:
Connected to IP
220 (vsFTPd 3.0.2)
331 Please specify the password.
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
200 Switching to Binary mode.
local: /home/user01/tmp/log.tgz remote: E1/180418090056
200 PORT command successful. Consider using PASV.
425 Failed to establish connection.
221 Goodbye.
和一个成功的:
Connected to IP
220 (vsFTPd 3.0.2)
331 Please specify the password.
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
200 Switching to Binary mode.
local: /home/user01/tmp/log.tgz remote: E1/180418090344
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 Transfer complete.
6901 bytes sent in 0.00 secs (43.5848 MB/s)
221 Goodbye.