bnosac / taskscheduler Goto Github PK
View Code? Open in Web Editor NEWSchedule R scripts/processes with the Windows task scheduler.
Schedule R scripts/processes with the Windows task scheduler.
I try to execute installation commands, but it isn't work.
I have a one Error: "installation of package ‘taskscheduleR’ had non-zero exit status". Then, I can't invoke library.
install.packages("taskscheduleR", repos = "http://www.datatailor.be/rcube", type = "source")
Warning: dependency ‘data.table’ is not available
trying URL 'http://www.datatailor.be/rcube/src/contrib/taskscheduleR_1.0.tar.gz'
Content type 'application/x-gzip' length 146885 bytes (143 KB)
downloaded 143 KB
ERROR: dependency 'data.table' is not available for package 'taskscheduleR'
The downloaded source packages are in
‘C:\Users\USER\AppData\Local\Temp\Rtmpk3LSz1\downloaded_packages’
Warning message:
In install.packages("taskscheduleR", repos = "http://www.datatailor.be/rcube", :
installation of package ‘taskscheduleR’ had non-zero exit status
library(taskscheduleR)
Error in library(taskscheduleR) :
there is no package called ‘taskscheduleR’
> tasks <- taskscheduler_ls()
Error in data.table::fread(f, ...) :
Expecting 28 cols, but line 147 contains text after processing all cols. Try again with fill=TRUE. Another reason could be that fread's logic in distinguishing one or more fields having embedded sep=',' and/or (unescaped) '\n' characters within unbalanced unescaped quotes has failed. If quote='' doesn't help, please file an issue to figure out if the logic could be improved.
Great idea, this package, I currently solve this via an externel scheduler + a database "job queue" table.
Would it be possible to add the required user right under which the R session must be run so that the scheduled tasks are accessible (and can be modified)?
With "user rights" I mean the required Windows groups, roles etc. ...
Thanks :-)
How can I schedule tasks every 5 minutes by using the RStudio-AddIn, i.e., equivalent to the example given in e.g. reference manual:
## Run every 5 minutes, starting from 10:40taskscheduler_create(taskname = "myfancyscript_5min", rscript = myscript,schedule = "MINUTE", starttime = "10:40", modifier = 5)
Thanks in advance...
I want to schedule daily jobs, but with code:
taskscheduler_create(taskname = "import_digitale_to_bigquery",
rscript = "C:/R/TaskScheduler/digitale_bigquery_import.R",
schedule = "DAILY",
starttime = format(Sys.time() + 120, "%H:%M"),
startdate = format(Sys.Date(), "%d/%m/%Y"))
I get error:
Warning message:
running command 'schtasks /Create /TN "import_digitale_to_bigquery" /TR "cmd /c C:/PROGRA~1/R/R-33~1.1/bin/Rscript.exe C:/R/TaskScheduler/digitale_bigquery_import.R >> C:/R/TaskScheduler/digitale_bigquery_import.log 2>&1" /SC DAILY /ST 16:57 /SD "30/06/2016" ' had status 16389
How should I alter the code or settings to get the job done?
One-time jobs work fine
Thanks
I return the below error when trying to run my task via rstudio plug-in. If I move extdata, what do I need to also run in R so the task scheduler can properly work?
Error in observeEventHandler: Make sure the RscriptRepository does not contain spaces, change argument
C:/Users/xx xx/Documents/R/win-library/3.4/taskscheduleR/extdata to another location on your drive which contains no spaces
I have a R script that simply read.csv some files from my local directory and create an object in R. Although the task is created successfully with the script running, the object is not created from my read.csv function.
I keep getting this message every time I want to access the add-in. Any advice on how to solve it?
Hi there
apologies if this seems really obvious. Is there a way we could specify days for the weekly tasks in the in the coding side or the interface?
Thanks,
J
Hello,
I have the following to create a task running an R file with a simple read.xlsx and write.xlsx command to test the scheduling aspect of the package. Once i run this, i get the "SUCCESS: The scheduled task "testing123testing" has successfully been created." message, but nothing happens in the folders i would expect the .xlsx output and the log files. Could you help?
taskscheduler_create(taskname = "testing123testing",
rscript = "C:/Users//Documents/R/win-library/3.3/taskscheduleR/extdata/scheduled-automation-test.R",
schedule = "ONCE",
starttime = format(Sys.time() +62,"%H:%M"),
startdate = format(Sys.Date(),"%d/%m/%Y",
Rexe = "C:/Program Files/R/R-3.3.2/bin/Rscript.exe"))
Thanks!!
-Nick
Is it possible to use taskscheduleR to select security options for running tasks while logged out like in Task Scheduler?
I'm running a script. Whenever I use the examples, a log file is only created for whenever I run "ONCE". The cmd pops up for a second and everything. If I run anything else, like "MINUTE", cmd does not pop up and it does not run. And creates no log file. Can you help me out?
Very handy package, thanks!
How can I specify the script to run from Monday to Friday but not on Weekends?
According to the error message days = only takes a length one character vector:
taskscheduler_create(...,
schedule = 'WEEKLY',
days = list(c('MON','TUE','WED','THU','FRI')),
)
Error in match.arg(days) : 'arg' must be NULL or a character vector
taskscheduler_create(...,
schedule = 'WEEKLY',
days = c('MON','TUE','WED','THU','FRI'),
)
Error in match.arg(days) : 'arg' must be of length 1
By the way, does the language of the locale matter as we specify english lables
This is similar to issue #10.
If your R installation location has a space it your script will also fail. For a lot of corporate users we don't have a say as to where R gets installed.
Here we have \<directory with a space>\R.
All scripts built with taskscheduleR fail with
'///<directory' is not recognized as an internal or external command,
operable program or batch file.
Is there a way to default the cmd window to stay minimized while the process runs? I have a script that takes some time and is run often and the pop up is frequent. Is this something that is possible within the package?
[1] "ERROR: Invalid value for /D option."
[2] "Type "SCHTASKS /CREATE /?" for usage."
attr(,"status")
[1] 16389
library(taskscheduleR)
SUAM_4_1_script<- "U:/ModelSchedules/taskR.R"
taskscheduler_create(taskname = "SUAM_4_1",
rscript = SUAM_4_1_script,
schedule = "MONTHLY",
startdate = as.Date(cut(Sys.Date(), "month"))+19,
starttime = "03:00"
)
Can the package be updated to allow spaces in the path name to the script? For example, here is my code:
Midlandscript <- file.path("S:/Weather Forecasts/R programming", "Midland_Daily.R")
taskscheduler_create(taskname = "myMidlandscript", rscript = Midlandscript,
schedule = "ONCE", starttime = format(Sys.time() + 5, "%H:%M"))
However, the S drive is a shared folder, and my IT folks do not want to add another folder (with no spaces) for some unknown reason. Thus, I can not change the folder name to something like this:
Midlandscript <- file.path("S:/Weather_Forecasts/R_programming", "Midland_Daily.R")
An option is using my hard drive (something like "C:\temp"), but that is not backed up like a network drive.
Thank you.
Already install the latest version from Github.
> packageVersion('taskscheduleR')
[1] ‘1.1’
When trying to create task, error says:
Warning: Error in match.arg: 'arg' should be one of “*”, “MON”, “TUE”, “WED”, “THU”, “FRI”, “SAT”, “SUN”, “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “10”, “11”, “12”, “13”, “14”, “15”, “16”, “17”, “18”, “19”, “20”, “21”, “22”, “23”, “24”, “25”, “26”, “27”, “28”, “29”, “30”, “31”
Stack trace (innermost first):
69: match.arg
68: taskscheduler_create
67: observeEventHandler
3: shiny::runApp
2: shiny::runGadget
1: taskscheduleR:::taskschedulerAddin
ERROR: [on_request_read] connection reset by peer
Any idea on this?
Hi while installing the package
library(devtools)
devtools::install_github("jwijffels/taskscheduleR")
the following error message is returned:
Downloading GitHub repo jwijffels/taskscheduleR@master
from URL https://api.github.com/repos/jwijffels/taskscheduleR/zipball/master
Error in curl::curl_fetch_memory(url, handle = handle) :
Couldn't resolve host name
How can I resolve this?
For solutions like http://stackoverflow.com/questions/17783686/solution-how-to-install-github-when-there-is-a-proxy I need special configuration.
Hi, thank you for this fantastic script. So i tested this using a simple script that contains this line:
print("hello world")
so i scheduled it for minutely. But on the R console, I cant see any thing ran.
Then i tried another script:
library(data.table)
setwd("D:/")
test <- data.frame(a = 1, b= 2, c=3)
fwrite(test,"deleteme.csv")
Again, nothing happens. Can you help me because there are some task i wish to automate. Question 2: Also does this work when R studio is not open or only when R studio is opened.
Everything is done using the add-in
install.packages("taskscheduleR", repos = "http://www.datatailor.be/rcube", type = "source")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘taskscheduleR’ is not available (for R version 3.4.1)
The installation from the alternative source was successful however the package doesn't work for me.
I try to run, in order to test it, the example R file Hello World::
myscript <- system.file("extdata", "helloworld.R", package = "taskscheduleR")
taskscheduler_create(taskname = "myfancyscript", rscript = myscript,
schedule = "ONCE", starttime = format(Sys.time() + 62, "%H:%M"))
In 62 secs goes on a black window up and in a sec disappears. That's it the codes messages do not appear in the console.
in addition:
tasks <- taskscheduler_ls()
Error in $<-.data.frame(tmp, "TaskName", value = character(0)) :
replacement has 0 rows, data has 149str(tasks)
Error in str(tasks) : object 'tasks' not found
I also created my own script that writes a .csv, doesn`t work neither. Is there something that I neglected in the code or in the settings?
I created a script that adds a line to a text file. I then scheduled the task to run on "MINUTE" with modifier = 2 (every two minutes). I expect to see lines added to the text file every two minutes, but that is not the case. Any help would be appreciated.
Best, Bledar.
Today is 5th of April, I am trying to schedule a task by minute starting in five minutes. Start date display on GUI is '2018-04-05' however it does not run until I change it to '2018-05-04'. not sure if this is a bug or it suppose to be this way.
I am getting this error:
taskscheduleR:::taskschedulerAddin()
Error in taskscheduleR:::taskschedulerAddin() :
Make sure the RscriptRepository does not contain spaces, change argument C:/Program Files/R/R-3.2.1/library/taskscheduleR/extdata to another location on your drive which contains no spaces
can we...?
should be easy to add as a param. i'll do later perhaps.
trying to run monthly task scheduling with the following:
myscript <- system.file("extdata", "helloworld.R", package = "taskscheduleR")
taskscheduler_create(taskname = "test_myscript_monthly",
rscript = myscript,
schedule = "MONTHLY",
months = "*",
days = "THU",
startdate = format(as.Date(Sys.Date()) + 2, '%m/%d/%Y'))
but got the following error:
Warning: running command 'schtasks /Create /TN "test_myscript_monthly" /TR "cmd /c C:/PROGRA1/R/R-331.1/bin/Rscript.exe C:/Users/lopezf/Documents/R/win-library/3.3/taskscheduleR/extdata/helloworld.R >> C:/Users/lopezf/Documents/R/win-library/3.3/taskscheduleR/extdata/helloworld.log 2>&1" /SC MONTHLY /ST 12:21 /SD "11/05/2016" /D THU /M * ' had status 16389
[1] "ERROR: Invalid value for /D option." "Type "SCHTASKS /CREATE /?" for usage."
attr(,"status"
my 'weekly', 'daily' and 'once' work fine. Any ideas what it might be? Thank you!
Hi Jan, I have this simple script:
x0 = 5.9
a <- seq(x0, 6, 0.01)
b <- mean (a)
write.table(b, "C:/01 - Andrea/mydata.txt", sep="\t")
Scheduled with the following code:
library(taskscheduleR)
wma <- file.path("C:", "01 - Andrea", "myscript.R")
taskscheduler_create(taskname = "myscriptdaily", rscript = wma,
schedule = "DAILY", starttime = "17:37", startdate = format(Sys.Date()+1, "%d/%m/%Y"))
Now, I am not using the computer of the Bank where I work, but I am using my personal computer.
But still, I have problem: the mydata.txt is not produced.
Why?
Thanks?
A
Hi, thanks for this great package!
I am using the addin and when I run my script once, everything works fine with locale "%Y-%m-%d".
However, when I delete the old task and set up a new one with Schedule DAILY I get the additional status 16389 message and no script is sent to the task folder.
Would appreciate any help on this!
Stop task button does not stop repeated tasks, it only stops the current running task.
Delete task button stop the task properly but it also deletes the R script from folder.
Hey,
So now I'm trying to run the ONIDLE tasking to try and have a task run at 15 minute intervals; my understanding is that ONIDLE would allow me to do this. I've been using the following code. The task schedules but then when I check tasks <- taskscheduler_ls() I notice that the "next running time" = NA and the task doesn't run at all. Any ideas what I might be doing wrong? Thank you!
myscript <- system.file("extdata", "helloworld.R", package = "taskscheduleR")
taskscheduler_create(taskname = "myscript",
rscript = myscript,
schedule = "ONIDLE",
startdate = format(as.Date(Sys.Date()), '%m/%d/%Y'),
starttime = "21:40",
idletime = 15)
I'm trying to run a script once every minute for 2 hours and then stop. I couldn't find any examples of this in your examples. Is it possible to set an endtime in taskscheduleR?
Would it be possible to allow for more flexible schedules in the Rstudio addin? Specifically I would find yearly and quarterly schedules useful, but the ability to set arbitrary ones could also come in handy.
I keep getting an error when selecting MONTHLY schedule.
taskscheduler_create(taskname = "myfancyscript", rscript = myscript, schedule = "MONTHLY")
By looking at the source code, this should be autocompleted by default values for startdate, months, days?
[1] "Fout: ongeldige waarde voor optie /D." "Typ SCHTASKS /CREATE /? voor de syntaxis. attr(,"status") [1] 16389 Warning message: running command schtasks /Create /TN "myfancyscript" /TR "cmd /c C:/R/R-32~1.3/bin/Rscript.exe c:/R/Libs/taskscheduleR/extdata/helloworld.R >> c:/R/Libs/taskscheduleR/extdata/helloworld.log 2>&1" /SC MONTHLY /ST 15:50 /SD "18/03/2016" /D * /M * had status 16389
Hi there,
I've been trying to use your nice package to schedule some daily tasks but I ran into some problems.
Namely, when testing with a dummy script that just contains a call to runif(100)
, everything is alright as long as the schedule
is set to ONCE
.
taskscheduleR::taskscheduler_create(
taskname = "test_scheduler",
rscript = "C:/Users/DavidJankoski/Desktop/scheduler_test.R",
schedule = "ONCE",
Rexe = "C:/Program Files/R/R-3.3.0/bin/Rscript.exe",
starttime = format(Sys.time() + 32, "%H:%M"))
#[1] "SUCCESS: The scheduled task \"test_scheduler\" has successfully been created."
Script goes through fine. However, when i set the schedule = ONLOGON
then it breaks with the following error msg
taskscheduler_create(taskname = "test_scheduler",
rscript = "C:/Users/DavidJankoski/Desktop/scheduler_test.R",
schedule = "ONLOGON",
Rexe = "C:/Program Files/R/R-3.3.0/bin/Rscript.exe",
starttime = Sys.Date() + 1)
# error message
[1] "ERROR: Access is denied.\r"
attr(,"status")
[1] 1
Warning message:
running command 'schtasks /Create /TN "test_scheduler" /TR "cmd /c C:/Program Files/R/R-3.3.0/bin/Rscript.exe C:/Users/DavidJankoski/Desktop/scheduler_test.R >> C:/Users/DavidJankoski/Desktop/scheduler_test.log 2>&1" /SC ONLOGON ' had status 1
Seems like some administrator issues?
Here's my session info, I'm running win10 home v1607, tried it on MRO 3.3.2 and R 3.3.0, as well as setting explicitly the Rexe
path to standard R (not MRO) and i get the same error. Also i tried consulting the docs in your package (running cmd line) but without any success (/SC was not recognized as an arg somehow). Any ideas on what could be going wrong?
thanks,
david
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RevoUtilsMath_10.0.0
loaded via a namespace (and not attached):
[1] RevoUtils_10.0.2 tools_3.3.2 data.table_1.10.4 taskscheduleR_1.0
When I run my task instantly, logs are not getting written to log file in the same path which got created instead it is being written to cmd.exe. The moment anything fails cmd gets closed and also, loga are lost.
Hi,
I'm sending these 2 commands:
taskscheduler_create(taskname = "indices.task", rscript = indices.script,
schedule = "DAILY", starttime = "09:10", startdate = format(Sys.Date()+1, "%m/%d/%Y"))
taskscheduler_create(taskname = "lowest.task", rscript = lowtea.script,
schedule = "WEEKLY", starttime = "07:10", days = 'SUN')
first task created successfully
and the second return the following error:
[1] "ERROR: Value for '/TR' option cannot be more than 261 character(s)."
attr(,"status")
[1] 16389
Hi,
this is very cool but wouldn't it be possible to unify with https://github.com/bnosac/cronR?
So you would have a common platform independant way to make tasks.
I am trying to use taskscheuleR (the add-in for Rstudio), but the code I am trying to schedule needs to be changed and updated daily or weekly. Right now I can't seem to start a task and update the code at a later time, saving it with the same name in the same place, and have the task run with the new updated code. Is there any way around that or is that just what it will do or am I missing something? Any help would be great.
Using taskscheduleR we run scripts every 5 minutes. Hence every 5 minutes a cmd.exe window shows up and fetches the gui focus. This is very annoying for the user and I wanted to ask if there is a way to eliminate this behavior. This supposedly would not happen if tasks are created as system tasks.
Hi,
I am not able to run the taskscheduler_ls() function, I get an error related to the fread function of data.table.
Error in data.table::fread(f) :
Expected sep (' ') but new line, EOF (or other non printing character) ends field 4 when detecting types ( first):
ERRORE: impossibile caricare l'attivit…: ATKOSD2
In addition: Warning message:
In data.table::fread(f) :
Starting data input on line 2 and discarding line 1 because it has too few or too many items to be column names or data: ERRORE: impossibile caricare l'attivit…: Adobe Acrobat Update Task
I could correctly schedule and run the script, but I do not know how to view all scheduled tasks with this issue with taskscheduler_ls().
Thanks for helping and for the awesome package!
Streaming twitter (rtweet package) works fine for me when manually running the code - but not when scheduling the task using the RStudio-AddIn (stops immediately after it starts running). Any idea...?
Loading and saving the access token:
library("rtweet")
appname <- "herr[...]mann"
key <- "SzA[...]1o7u"
secret <- "4MtSJom[...]WjdgRUuz"
twitter_token <- create_token(app = appname, consumer_key = key, consumer_secret = secret)
saveRDS(twitter_token, "twitter_token.rds")
Then scheduling (or manually running) the task:
library("rtweet")
twitter_token <- readRDS("twitter_token.rds")
stream_tweets(q = "election", file_name = "...", timeout = 60)
Thanks for any hint...
Hi Jan,
I am Andrea Perlato from Swizerland.
Sorry if tI disturb you but I really need to schedule the following R script named MyScript.R:
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
So, I created the atsk with the following code:
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 sussessfull created.
But, when arrive the 06:00 it seems that the MyScript.R doen't run, because the mydata.txt in not produced in the C:/Andrea/R/ folder.
Moreover, I tryed to cancel the mytask just created with:
taskscheduler_delete(taskname="mytask")
But it ays: Acess Deny.
Could you help me please to solve it. I really need to use the scheduleR.
Thank you,
Kind regards,
Andrea
Hello,
I tried to run a daily R script using the rstudio add-in and receive the following error:
ERROR: The system cannot find the file specified.
Warning: running command 'schtasks /Delete /TN "getsurvey.R" /F' had status 1
Creating task schedule: schtasks /Create /TN "getsurvey.R" /TR "cmd /c C:/PROGRA1/R/R-341.1/bin/Rscript.exe "C:/Users/Administrator/Documents/R/FWP/getsurvey.R" >> "C:/Users/Administrator/Documents/R/FWP/getsurvey.log" 2>&1" /SC DAILY /ST 12:10 /SD "18/07/2017"
Warning: running command 'schtasks /Create /TN "getsurvey.R" /TR "cmd /c C:/PROGRA1/R/R-341.1/bin/Rscript.exe "C:/Users/Administrator/Documents/R/FWP/getsurvey.R" >> "C:/Users/Administrator/Documents/R/FWP/getsurvey.log" 2>&1" /SC DAILY /ST 12:10 /SD "18/07/2017" ' had status 16389
If I run it as ONCE is runs fine.
Anything ideas?
Thanks!
Do you plan on updating your package to R 3.4.4?
We're running this version (with RStudio) on our server and unfortunately I can't install taskscheduleR (whcih I would love to...).
The default setting is that the task will only run when my laptop is plugged in. Is there a way to change this setting to allow tasks to run even when not plugged in?
Hey,
Task Scheduler does not run the task.
at first I ran the example code you have in README, it did not work so I opened tasks dataframe and found out that the last run time did not changed and there is no log.
So I've moved the helloword file to another location( C:\taskscheduler ) and I change the myscript to this
myscript <- 'C:\taskscheduler\helloworld.R'
mylog <- 'C:\taskscheduler\helloworld.log'
taskscheduler_create(taskname = "myfancyscript", rscript = myscript,
schedule = "ONCE", starttime = format(Sys.time() + 62, "%H:%M"))
but It still does not run it.
I think there is something wrong with the Task to Run part :
cmd /c C:/PROGRA1/R/R-341.3/bin/Rscript.exe "C:\taskscheduler\helloworld.R" >> "C:\taskscheduler\helloworld.log" 2>&1
I really appreciate your help
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.