Description Usage Arguments Examples
Run tasks in a schedule
1 2 |
Schedules |
An ordered vector with the schedules for each task in shorthand period:offset form |
TasksInfo |
Ordered Structure with extra information which will be passed to handler |
method |
Whether a function (callback) or a program should be called |
handler |
The name of the function which handles the task execution |
... |
Extra arguments to be passed to the handler |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # Define a handler
my_handler <- function(task_id, timestamp, tasks_info) {
# Do something with this "task_id" using the information in "tasks_info"
message("Running ", task_id, " at ", unclass(Sys.time()), " - scheduled: ",
timestamp, " (", as.POSIXct(timestamp, origin = "1970-01-01") , ")")
}
# Define the tasks info structure
my_tasks <- data.frame(schedules = c("2s", "1m:3s", "1h:5s"),
my_jobs = c("job01", "job02", "job03"),
other_info = c("...", "...", "..."),
stringsAsFactors = F)
# create the schedules vector
schedules <- my_tasks$schedules
# Start the scheduler
crond(schedules, my_tasks, "callback", "my_handler")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.