0

I'm trying to follow the conventional method to trigger R scripts through batch like

RScript Example.R

but what i look to is some way to run multiple R scripts through a batch file.

I tried to do use Start command to open multiple sessions but that doesn't work either. (RScript START ex1.R START ex2.R)

PS complete noob to batch files.

user3338307
  • 21
  • 2
  • 5

3 Answers3

4

On Windows - if you want to run them in parallel make sure you add start in yoyr batch (.bat) script. Otherwise Example2.R waits for Example1.R to complete etc.

start RScript Example1.R
start RScript Example2.R
...
michalrudko
  • 1,432
  • 2
  • 16
  • 30
0

If you're using sh to launch your scripts, this could do it.

cd /path_to_script1/
sh script1.sh &
cd /path_to_script2/
sh script2.sh &
cd /path_to_script3/
sh scipt2.sh &

This launches parallel R sessions (one for each script) so careful with memory and CPU use. Each script file contains Rscript command.

Vivi
  • 65
  • 7
  • As of now I have the statement RScript Example.R in a .bat file and i execute the.bat file. Can i do that with .sh extension given that im on a windows system? – user3338307 May 11 '17 at 12:28
  • probably not the best but you can run sh files in windows using cygwin terminal – Vivi May 11 '17 at 12:52
0

Simply save the RScript commands in a Windows batch file (.bat) then double-click the file in directory or call it via command line. Below assumes RScript is an environment variable.

Batch file (type below in Notepad and save with extension .bat, not default .txt)

cd "C:\Path\To\Scripts"

RScript Example1.R
RScript Example2.R
RScript Example3.R
RScript Example4.R
RScript Example5.R

CMD Command line

call myRScriptBatchFile.bat

PowerShell Command line

cmd.exe /c myRScriptBatchFile.bat
Parfait
  • 104,375
  • 17
  • 94
  • 125