ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

ftp自动同步,如何设置ftp自动同步及环境配置方法

2020-09-29 23:51:46  阅读:250  来源: 互联网

标签:ftp 同步 FTP 自动 File println new 上传


IIS7服务器管理工具-FTP客户端
作为FTP客户端,它支持批量管理FTP站点
具体功能:
FTP定时上传和定时下载,FTP定时备份,且操作简洁
iis7服务器管理工具还是vnc客户端
支持批量管理管理windows及linux服务器、vps
让服务器真正实现了一站式管理,真的是非常方便。

官网传送门:fwqglgj.iis7.net/cp/ftp/?tscd-zc

配置方式:

一、选择ftp窗口,点击FTP设置

二、进入“FTP设置”—“任务设置”后,我们先添加任务

1、新建任务(一个任务只能选择一种时间周期)

1-1:如何设置 天级定时上传或下载任务

image

1-2:如何设置 周级定时上传或下载任务

image

1-3:如何设置 月级定时上传或下载任务

image

注意点:备份类型的选择

追加:新文件。

修改:新文件,或者修改内容后的文件。

覆盖:不对比文件,直接覆盖原文件。(不推荐)

2、接下来选择FTP(以下示例定时上传操作教程)

2-1:点击“选择FTP”

image

2-2:进入FTP绑定界面

image

2-3:成功绑定一台ftp站点

image

2-4:ftp绑定信息及任务执行结果会在设置界面下方显示

image

三、提示任务上传成功之后,我们去对应ftp服务器查看任务是否上传完成

经查看,文件已成功上传!

image

注意:本文以上传为例,如果需要下载只要将传输方向改为“下载”即可!

java配置方式如下:

import com.enterprisedt.net.ftp.*;
public class FtpClient {
static FTPClient ftpClient;
public FtpClient(){};
String remoteAddress="192.168.168.33",userName="cattsoft",password="cattsoft";
public void DownLoad(){
try{
FTPClient client = new FTPClient();
client.setRemoteHost(remoteAddress);
client.connect();
client.login(userName,password);
client.setType(FTPTransferType.BINARY);
client.get("E:uploadindex.jsp","/home/cattsoft/jakarta-tomcat-5.0.28/webapps/vip/dkf/index2.jsp");
client.quit();
System.out.println("下载成功...");
}catch(Exception e){
e.printStackTrace();
System.out.println("下载失败...");
}
}
public static void main(String[] args){
FtpClient fc = new FtpClient();
fc.DownLoad();
}
}
java下配置连接FTP:
public void putTxtToFTP() {
System.out.println("开始执行定时器任务:维系一键订单量!");
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, -1); //得到前一天
Date date = calendar.getTime();
SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
String yesterday = df.format(date);
StringBuffer yjtjOrderTxt = new StringBuffer();
yjtjOrderTxt.append("yjtywx_").append(yesterday).append(".txt");
List<WxActiveData> yjtjOrderList = activeDataService.wxGetYjtjOrder();
//FtpUtil ftpUtil = new FtpUtil("hexin","hx105155","134.64.105.155", "/yjtydd");  //测试库FTP
FtpUtil ftpUtil = new FtpUtil("ahftp","ahdx@#$_123dic","192.168.0.28", "/yjtydd");
PrintWriter printWriter = null;
File highFeeFile = new File(Contants.FILE_PATH_BAK + yjtjOrderTxt);//Contants.FILE_PATH_BAK = "/opt/wss/domains/tmp/"
//      File highFeeFile = new File("D:/" + highFeeTxt);
//      File gjmyFile = new File("D:/" + gjmyTxt);
//File highFeeFile = new File("D:/" + yjtjOrderTxt);
try {
printWriter = new PrintWriter(new FileWriter(highFeeFile, true));
for (int i = 0; i < yjtjOrderList.size(); i++){
printWriter.println(yjtjOrderList.get(i).toString().trim());
}
} catch (IOException e) {
System.out.println("主动服务 高额数据报表任务异常!");
}finally{
printWriter.close();
}
if(highFeeFile.exists()){
System.out.println("主动服务定时器任务 高额数据 上传成功"+yjtjOrderTxt.toString());
ftpUtil.uploadFile(highFeeFile, yjtjOrderTxt.toString());
}else{
System.out.println("主动服务定时器任务 高额数据 上传失败"+yjtjOrderTxt.toString());
}
System.out.println("服务器批量查排名-查询结果");
}
public ActiveDataService getActiveDataService() {
return activeDataService;
}
public void setActiveDataService(ActiveDataService activeDataService) {
this.activeDataService = activeDataService;
}​

标签:ftp,同步,FTP,自动,File,println,new,上传
来源: https://blog.51cto.com/14937269/2539357

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有