bnosac / taskscheduleR

Schedule R scripts/processes with the Windows task scheduler.
330 stars 72 forks source link

Issue with log File for Scheduled Task #79

Closed JuneKay92 closed 3 years ago

JuneKay92 commented 3 years ago

I am trying to create a simple task that will run only once to try and understand this package. I am trying to create a task using the function taskscheduler_create(), however I have no idea where the log ends up. It does not appear in the folder with the rscript or the file that creates the task. I know I could use the addin to set where the log goes explicitly, but I would like to be able to do this just through code. Please help me figure out where the output log file ends up!

R script:

nums <- sample(100, 10)

print(nums)

Scheduler:

taskscheduler_create(taskname = "test_run", 
                     rscript = "auto_task/create_file.R", 
                     schedule = "ONCE",
                     starttime = format(Sys.time() + 50, "%H:%M"))
jwijffels commented 3 years ago

If there is no log it didn't run. Look to the README. In particularly the last section on the startdate: https://github.com/bnosac/taskscheduleR#mark-on-error-messages and provide the full path to the file in rscript as documented in ?taskscheduler_create

JuneKay92 commented 3 years ago

Thank you. It was because I didn't use the full path the the Rscript file. Is there a way to get it to use the working directory?

jwijffels commented 3 years ago

My advise: learn to use environment variables instead of relative paths or the package here. See