Search code examples
rr-taskscheduler

How to schedule taskscheduleR once a month at the start of every month?


Looking to run R script once a month at the first of every month.I've figured out how to run it via task scheduler with the taskscheduleR library. Here is the current cadence I have set on it:

taskscheduler_create(taskname = "Rebate Automation2", rscript = myscript, 
                     schedule = "MONTHLY", starttime = "12:30")

I am unsure how to set it for the first of every month.


Solution

  • From the package documentation:

    days     character string with days on which to run the script if schedule is
    ’WEEKLY’or ’MONTHLY’. Possible values are * (all days). For weekly: ’MON’,
    ’TUE’,’WED’, ’THU’, ’FRI’, ’SAT’, ’SUN’ or a vector of these in your locale. 
    For monthly: 1:31 or a vector of these.
    

    Therefore taskscheduler_create(taskname = "Rebate Automation2", rscript = myscript, schedule = "MONTHLY", days=1, starttime = "12:30")

    Should do the job.