Issues running a WEEKLY task
alapo opened this issue · comments
Hello,
I apologize ahead of time if this issue is silly. I am trying to run a WEEKLY tasks. For reproducibility I am using the code in the vignette shown below
library(taskscheduleR)
myscript <- system.file("extdata", "helloworld.R", package = "taskscheduleR")
## Run every week on Saturday and Sunday at 09:10
taskscheduler_create(taskname = "myfancyscript_sunsat", rscript = myscript,
schedule = "WEEKLY", starttime = "09:10", days = c('SUN', 'SAT'))
Running this code leads to the following error
[1] "ERROR: Invalid Start Date (Date should be in \"yyyy/mm/dd\" format).\r"
attr(,"status")
[1] 16389
Warning message:
In system(cmd, intern = TRUE) :
running command 'schtasks /Create /TN "myfancyscript_sunsat" /TR "cmd /c C:/PROGRA~1/R/R-40~1.4/bin/Rscript.exe \"C:/Users/Gertrude/Documents/R/win-library/4.0/taskscheduleR/extdata/helloworld.R\" >> \"C:/Users/Gertrude/Documents/R/win-library/4.0/taskscheduleR/extdata/helloworld.log\" 2>&1" /SC WEEKLY /ST 09:10 /SD "02/08/2021" /D SUN,SAT ' had status 16389
What I have done to troubleshoot the issue
I have looked throughout the repo for similar issues, I have attempted them and they fail to fix my problem. Below is a recap
-
Looked up this question on StackOverflow
-
Issue 15 which recommended checking the number of character is less than 260
- Does not apply to this code since the number of characters is 80
-
Tried the code from Issue 11 but this gives me an
"ERROR: Invalid Start Date (Date should be in \"yyyy/mm/dd\" format).\r"
error
If anyone has any advice on this error it would be greatly appreciated. I can create a task using other timelines.
Testing a task ONCE
For example running it once as shown below does work
library(taskscheduleR)
myscript <- system.file("extdata", "helloworld.R", package = "taskscheduleR")
## run script once within 62 seconds
taskscheduler_create(taskname = "myfancyscript", rscript = myscript,
schedule = "ONCE", starttime = format(Sys.time() + 62, "%H:%M"))
Testing Task DAILY
Gives me the Invalid Start Date
error I changed the starttime
argument
library(taskscheduleR)
myscript <- system.file("extdata", "helloworld.R", package = "taskscheduleR")
## Run every week on Saturday and Sunday at 09:10
taskscheduler_create(taskname = "myfancyscript_sunsat", rscript = myscript,
schedule = "WEEKLY", starttime = "09:10", days = c('SUN', 'SAT'))
so I changed the format of startdate
taskscheduler_create(taskname = "myfancyscript_sunsat",
rscript = myscript,
schedule = "WEEKLY",
startdate = format(Sys.Date(), "%Y/%m/%d"),
starttime = "09:10",
days = "1",
)
But this still gave me an error
[1] "ERROR: Invalid value for /D option." "Type \"SCHTASKS /CREATE /?\" for usage."
attr(,"status")
[1] 16389
Have you tried
taskscheduler_create(taskname = "myfancyscript_sunsat",
rscript = myscript,
schedule = "WEEKLY",
startdate = format(Sys.Date(), "%Y/%m/%d"),
starttime = "09:10",
days = c('SUN', 'SAT')
)
That's perfect! Is this something that changes on a system to system basis?
Yes, it depends on how you setup Windows in particular your locale settings of Windows.