文章说明
为了方便同步不在同一局域网内的机器,使用定时器执行以下脚本(需要安装winscp),定时同步文件
bat脚本 创建xxx.bat脚本调用run.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 @echo on rem echo是off 不打印注释rem title 同步文件 :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: 同步文件 :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: cd "C:\Program Files (x86)\WinSCP\" ::以命令行方式同步数据 set data=%date:~0,4%%date:~5,2%%date:~8,2% "C:\Program Files (x86)\WinSCP\WinSCP.exe" /console /script=C:\Users\JUNO\Desktop\run.txt /log=C:\log\%data%-log.txt pause
run.txt ftp使用的run.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 # winscp.exe /console /script=sample.txt # Automatically answer all prompts negatively not to stall # the script on errors # option echo on|off option echo off # option batch on|off|abort|continue option batch on # option confirm on|off #无需确认直接操作 option confirm off # option transfer binary|ascii|automatic #服务端如果没有该文件,则将本地文件删除 # option synchdelete on|off # option exclude clear | <mask > [;<mask2 > ...] # option include clear | <mask > [;<mask2 > ...] option synchdelete off # open [ sftp|ftp|scp:// ][ [ :password ] @ ] <host > [ :<port > ] # open user:password@example.com # Connect FTP地址 open ftp://yd-video:ABCabc123@183.236.23.5:33035 # Change remote directory # 如果同步到远程FTP时,可用此命令转到远程某个目录下 cd /backup/ # Change local directory # set to Self's working dir 设置需要同步到远程FTP的本地文件目录 lcd C:\Users\JUNO\Desktop\Learn # Force binary mode transfer # 使用二进制格式传送 option transfer binary # Download file to the local directory d:\ # 拉取文件到本地 # get examplefile.txt d:\ # synchronize local|remote|both [ <local directory > [ <remote directory > ] ] # 从远程同步到本地用Local;从本地同步到远程用Remote synchronize remote # Disconnect close # Exit WinSCP exit