Windows Batch로 R 스크립트 자동실행

오늘은 윈도우 배치 파일(.bat)로 크롤링을 자동화하는 방법을 이야기하렵니다.


샘플 코드는 다음과 같습니다.

@echo off
:LOOP
echo %date% %time% Starting...
start "Run1" RScript Run1.R
start "Run2" RScript Run2.R
start "Run3" RScript Run3.R
start "Run4" RScript Run4.R
start "Run5" RScript Run5.R
start "Run6" RScript Run6.R
start "Run7" RScript Run7.R
start "Run8" RScript Run8.R
start "Run9" RScript Run9.R
start "Run10" RScript RNavHotelRun11.R
REM 12 hours loop
timeout /t 43200 /nobreak
goto LOOP
각각의 명령어에 관한 설명입니다.
@echo off  /* 명령어가 안보이게 하기 */
:LOOP /*goto로 이동할 위치 */
echo /*메시지 출력*/
start "title" cmd /*프로세스 실행*/
REM /*주석*/
timeout /t /*초로 표시, sleeping... */
goto /*지정된 곳으로 이동*/


이상입니다. 코드는 .bat 파일로 저장하여 실행하면 됩니다.

댓글

이 블로그의 인기 게시물

R에서 csv 파일 읽는 법

xlwings tutorial - 데이터 계산하여 붙여 넣기