Automating the Execution of various R Scripts on Windows.

How to run more than one script from the console or from the windows task scheduler.

There is nothing preventing you from running several scripts from different consoles.

Create an R script with the code:

message("Will sleep...")

and save it as sleep.R. Then, open two cmd.exe, use cd to go into the directory with the script, and, in each cmd, call the R script with:

Rscript.exe sleep.R

You can start the same script on the second terminal before the first has finished running, there is nothing preventing you to do that. It will just create 2 R sessions, as you can see in the Task Manager:

If the question is about starting the script and getting back control in the same terminal, you want to run it in the background. Indeed, in a single console, you can start:

start /b Rscript.exe sleep.R

You get the message "Will sleep...", you can immediately start a second, identical, command, and you will get the resulting "Slept!" for both scripts at the end.

I have no experience with the Task Scheduler, but I expect these to work as well in this context.

Note: it appears the script will be interrupted if you log off after starting it from the console, the Task Scheduler may be a workaround.

1 Like

Thank you very much the information was useful

1 Like

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.