Closed david-jankoski closed 7 years ago
you can not have 2 tasks with the same name, are you sure you removed the task 'test_scheduler' before you created a new task with the same name 'test scheduler'? Also, do you have admin rights as the README indicates?
Hi - thanks for getting back so quick.
I did remove the previously scheduled ONCE task and tried the following:
Sys.Date()+1
& as well as formatting variations of it)# script that will be scheduled - "test_schr.R" --------------
x <- runif(10)
sink("C:/Users/David_Jankoski/Desktop/test_sch1.txt")
x
sink()
then i tried the following
library("taskscheduleR")
# ONCE works ------------------------
taskscheduler_create(taskname = "test1",
rscript = "C:/Users/David_Jankoski/Desktop/test_sch.R",
schedule = "ONCE",
starttime = format(Sys.time() + 62, "%H:%M")
)
#> [1] "SUCCESS: The scheduled task \"test1\" has successfully been created."
# remove ONCE task
taskscheduler_delete(taskname = "test1")
#> SUCCESS: The scheduled task "test1" was successfully deleted.
# ONLOGON fails -----------------------
taskscheduler_create(taskname = "test2",
rscript = "C:/Users/David_Jankoski/Desktop/test_sch.R",
schedule = "ONLOGON",
starttime = Sys.Date() + 1
)
# The Error --------------------------
[1] "ERROR: Access is denied.\r"
attr(,"status")
[1] 1
Warning message:
running command 'schtasks /Create /TN "test2" /TR "cmd /c C:/PROGRA~1/MICROS~1/MRO-33~1.2/bin/Rscript.exe C:/Users/David_Jankoski/Desktop/test_sch.R >> C:/Users/David_Jankoski/Desktop/test_sch.log 2>&1" /SC ONLOGON ' had status 1
I double checked the admin rights and I do have them. Also - I am able to schedule the ONCE task successfully - i guess that would result in an error otherwise right? Let me know if i can provide some more information.
thanks, david
Did you ask your System administrator to make sure you have the rights to execute Schtasks.exe? ONLOGON is different than e.g. DAILY. ONLOGON means when you start your computer. Maybe your rights there are different than when your computer is already on.
have you also tried the examples in the README: https://github.com/bnosac/taskscheduleR
I managed to find the reason - your previous comment
ONLOGON means when you start your computer. Maybe your rights there are different than when your computer is already on
was a great hint and also due to my limited knowledge in these things...so even if i have admin account and all possible rights, i still had to explicitly start rstudio with admin rights in order to be able to do this. all the examples work and ONLOGON goes through successfully.
Sorry again, and thanks for all the help!
cheers, david
p.s. i think it might be helpful to just include a sentence in the docs that in case one wants to schedule ONLOGON tasks - make sure you start R/RStudio as an admin. You know - for people like me :)
good that it is solved added a remark in the readme
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 theschedule
is set toONCE
.Script goes through fine. However, when i set the
schedule = ONLOGON
then it breaks with the following error msgSeems 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