Board logo

标题: [文件操作] 求2个批处理的代码每隔20分钟备份sgt [打印本页]

作者: netdzb    时间: 2021-2-26 16:56     标题: 求2个批处理的代码每隔20分钟备份sgt

每隔20分钟,备份sgt为sgt-01,下一次的备份文件为sgt-02,

批处理怎么写?要是换成linux的shell又应该怎么写?
作者: smss    时间: 2021-2-26 17:26

本帖最后由 smss 于 2021-2-26 17:33 编辑
  1. @Echo off&SetLocal EnableDelayedExpansion
  2. :A
  3. set n=100&for /d %%i in (sgt*)do set /a n+=1
  4. xcopy /ciserh sgt sgt-!n:~1!&timeout /t 1200 /NOBREAK&goto A
复制代码

作者: shenlong    时间: 2021-2-26 17:28

@echo off
mode con cols=15 lines=11
color 0f
set n=1
:ks
if not exist sgt-0%n% copy /y sgt sgt-0%n%&&goto end
set /a n=n+1
goto ks
:end

保存为 bf.ba t然后再建立一个计划任务,每20分钟运行一次 bf.bat.
作者: netdzb    时间: 2021-2-26 17:50

回复 2# smss


感谢2位提供不同2种编程思路。
作者: netdzb    时间: 2021-2-27 07:36

回复 2# smss

如果这个需求用shell脚本如何写?




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2