1.首先在windows系统中建一个vbs文件,文件内容例如:
set os=createobject("wscript.shell")
do
wscript.sleep 2000(注解:这里是多长时间上传一次)
os.run "C:file.bat",0(注解:调用批处理文件,0标识不显示黑框)
Loop
2.建立批处理文件file.bat文件,内容:
@echo off
setlocal
rem 时间戳
set temp_dir=%time:~3,2%%time:~6,2%%time:~9,2%
set backup_port=22
set backup_user=服务器用户名
set backup_password=服务器密码
set backup_server=服务器地址
rem 目标服务器文件存放地址
set backup_path=/App/baogang/cc_kf/app/files/ai
rem 本地要上传的文件存放位置
set original_path=C:fileResults.csv
rem 上传文件
pscp -l %backup_user% -P %backup_port% -pw %backup_password% %original_path% %backup_server%:%backup_path%/%temp_dir%.csv
rem 删除本地文件
del %original_path%