以下是一份batch 脚本可以用于给嵌入式设备设置同步时间
大概的执行过程就是
① 从本地的电脑获得当前的时间
② 给嵌入式设备设置时区
③ 给嵌入式设备设置时间
④ 进行时间同步,将时间写入到rtc 时钟
@echo offcd ./srccd %~d0set server_ip=yourIPset date=%date:~0,4%-%date:~5,2%-%date:~8,2%set time=%time:~0,2%:%time:~3,2%:%time:~6,2%echo time now is %date% %time%plink.exe -ssh -l root -pw yourPasswd %server_ip% rm /etc/localtimeplink.exe -ssh -l root -pw yourPasswd %server_ip% ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtimeplink.exe -ssh -l root -pw yourPasswd %server_ip% date -s %date%plink.exe -ssh -l root -pw yourPasswd %server_ip% date -s %time%plink.exe -ssh -l root -pw yourPasswd %server_ip% hwclock -w -uecho set time done !TIMEOUT /T 20 /NOBREAK