I need to schedule the following R script:
remove(list=ls())
library(DBI)
library(ROracle)
drv <- dbDriver("Oracle")
connection <- dbConnect(drv, username="****", password="****", dbname="name_of_db")
mydata <- dbGetQuery(connection, "
SELECT Var1, Var2,
FROM Table
WHERE Var3 = '123' ")
write.table(mydata, "C:/Andrea/R/mydata.txt, sep="\t")
So, I just get data from Oracle, then I convert the result in .txt and save it in C:/Andrea/R.
I want to run it every day at 06:00 am, in order to have the .txt updated everyday in C:/Andrea/R
I want to do it with the R Packahe "taskscheduleR", and I made the syntax:
library(taskscheduleR)
wma <- file.path("C:", "Andrea","MyScript.R")
taskscheduler_create(taskname="mytask"), rscript = wma, schedule = "DAILY", starttime="06:00",
startdate=format(Sys.Date()+1. "%d/%m/%Y"))
So far so good: the "mytask" is successfully created. But, when we arrive at 06:00 it seems that the MyScript.R doesn't run, because the mydata.txt in not produced in the C:/Andrea/R/ folder.
Moreover, I tried to cancel the mytask just created with:
taskscheduler_delete(taskname="mytask")
But it says: Access Denied.
Could you help me please to solve it, please?