Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

running an R script in batch mode without the command prompt popping up

I have a scheduled task (using SCHTASKS) to run every minute.

SCHTASKS /Create /SC MINUTE /MO 1 /TN READSCALE /TR "Rcmd BATCH --vanilla --slave q:\workspace\waga\readScale.R"

On each run command prompt window pops up. It's slightly irritating and perhaps a potential health hazard for people with epilepsy. In Java, one can use javaw.exe (see this thread) that doesn't pop up a command prompt. Is there an equivalent for R?

like image 356
Roman Luštrik Avatar asked Jul 16 '11 19:07

Roman Luštrik


People also ask

How do I run an Rscript from a batch file?

Here's the steps: Download R from R Project and install into the shared drive. Open the .exe file found in the file path you just installed into, the file path will start with the R version you just downloaded and end with /bin/R.exe. Now that you have R running, install all of the packages your scripts need.

How do I run an Rscript in Terminal windows?

To open up the command prompt, just press the windows key and search for cmd. When R is installed, it comes with a utility called Rscript. This allows you to run R commands from the command line.


2 Answers

Kudos to serverfault.com, where some people solved the problem using no external tools at least in two ways. Here's the thread.

First is to write a .vbs script. This requires some knowledge of this scripting language and may not be appropriate for everyone.

The second method is to run the task (as I'm doing) under SYSTEM (and not the currently logged in user).

like image 197
Roman Luštrik Avatar answered Oct 14 '22 01:10

Roman Luštrik


Ah, Windows... There is a tool called hstart which may help here.

like image 33
mbq Avatar answered Oct 13 '22 23:10

mbq