windows定时任务的工作流程
- 新建一个扩展名为bat的批处理脚本文件。
- 创建定时任务,去执行bat脚本。
windows创建定时任务的具体步骤
1、新建一个bat脚本,这里创建一个拉取git仓的脚本
chcp 65001
@echo off
setlocal
@REM normalize the relative path to a shorter absolute path.
pushd "%~dp0"
set repos_path=%CD%
popd
call :find_and_pull %repos_path%
echo. & echo Finished. & pause>nul
goto :EOF
::-------------------------------------
:: @name find_and_pull
:: @param %1 base directory to find .git
:: @usage call :find_and_pull %base_dir%
::-------------------------------------
:find_and_pull
for /d %%i in (%1\*) do (
cd %%i
if exist .git (
echo. & echo [ START git pull FROM ] %%i
git pull
) else (
call :find_and_pull %%i
)
)
goto :EOF
2、设置定时任务
创建基本任务计划,位置:开始菜单->控制面板->管理工具->任务计划程序
点击创建基本任务之后,选择执行时间、执行的脚本位置即可。
配置完成之后检查: