如何在每个月的月初安排每月一次的taskscheduleR?

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

每个月 month.I 的第一天查看 运行 R 脚本一次,已经弄清楚如何通过任务调度程序和 taskscheduleR 库来 运行 它。这是我设置的当前节奏:

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

我不确定如何设置每个月的第一天。

来自包文档:

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.

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

应该完成这项工作。

可以找到 taskscheduleR::taskscheduler_create 的文档 (1) 按 F1 并单击函数调用 taskscheduler_create;或 (2) manual 的第 3 页和第 4 页。根据此文档,days 参数

taskscheduler_create(
  ...
  days = c("*", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN", 1:31),
  ...
)

可以为schedule = "MONTHLY"设置为days = 1,在每个月的第一天触发:

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.

所以你想使用

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