检查FTP服务器上的可用空间 [英] Checking free space on FTP server

查看:274
本文介绍了检查FTP服务器上的可用空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行,其中三个可执行文件(每个100MB)上传到FTP服务器构建脚本。

I am running a build script in which three executable files (100mb each) are uploaded to an FTP server.

所以我们的构建过程失败,第一次上传失败的可能原因FTP服务器空间的问题。这意味着我必须摆脱服务器的一些空间,然后再次运行构建脚本这是浪费时间。我想上传exe文件,以确保空间有前检查FTP大小。如果有足够的空间是存在的然后上传,否则提示用户输入。

The first upload can fail due to an FTP server space problem so our build process fails. This means I have to free some space from the server and run the build script again which is waste of time. I'd like to check the FTP size before uploading the exe to make sure space is there. If sufficient space is there then upload otherwise prompt user for input.

我如何检查FTP大小Ant脚本。

How can I check the FTP size in an ant script.

推荐答案

正如<一个讨论href=\"http://stackoverflow.com/questions/8135312/checking-free-space-on-ftp-server/8135434#8135434\">comments,你可以写沿行的shell脚本(假设FTP服务器是Linux箱):

As discussed in the comments, you can write a shell script (assuming the FTP server is a linux box) along the lines of:

#!/bin/bash

FTPDIR="/path/to/ftp/dir"
echo `df -kl / | tail | awk '{print $4}'` > ${FTPDIR}/free_space.txt

请确保您替换路径/到/ FTP / DIR 的实际路径,你会从被下载的目录。

Make sure you replace path/to/ftp/dir with the actual path to the directory you will be downloading from.

该脚本添加到服务器的的crontab crontab -e命令),并让它运行每隔一小时( 0 * * * * )左右。您也可以下载包含FTP服务器的每小时更新的可用空间 free_space.txt 文件。

Add that script to the server's crontab (crontab -e) and let it run every hour (0 * * * *) or so. You can download the free_space.txt file which contains the hourly updated free space of the FTP server.

这篇关于检查FTP服务器上的可用空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆