윈도우10, 작업스케줄러 배치파일 예제 (파이썬, 아나콘다)
set YEAR=%date:~0,4%
set MONTH=%date:~5,2%
set DAY=%date:~8,2%
set HOUR=%time:~0,2%
set MINUTE=%time:~3,2%
set SECOND=%time:~6,2%
set /a RND=%RANDOM% %% 10 + 5
set h0=%time:~0,2%
set m0=%time:~3,2%
set s0=%time:~6,2%
call conda activate crawling
cd C:\Users\username\crawling
echo event >> C:\Users\username\crawling\logs\event.log
echo %YEAR%-%MONTH%-%DAY% %HOUR%:%MINUTE%:%SECOND% >> C:\Users\username\crawling\logs\event.log
echo %RND% >> C:\Users\username\crawling\logs\event.log
timeout /t %RND%
call python execute.py 30 >> C:\Users\username\crawling\logs\event.log
set h1=%time:~0,2%
set m1=%time:~3,2%
set s1=%time:~6,2%
set /a h=h1-h0
set /a m=m1-m0
if %m% lss 0 (
set /a h=h-1
set /a m=m+60
)
set /a s=s1-s0
if %s% lss 0 (
set /a m=m-1
set /a s=s+60
)
echo %h%:%m%:%s% >> C:\Users\username\crawling\logs\event.log
댓글