cron_rscript | R Documentation |
Create a command to execute an R script which can be scheduled with cron_add where the stdout and stderr will be passed on to a log
cron_rscript( rscript, rscript_log = sprintf("%s%s.log", tools::file_path_sans_ext(rscript), ifelse(log_timestamp, "-`date+\\%Y-\\%m-\\%d_\\%H:\\%M:\\%S`", "")), rscript_args = "", cmd = file.path(Sys.getenv("R_HOME"), "bin", "Rscript"), log_append = TRUE, log_timestamp = FALSE, workdir = NULL, type = c("default", "output_on_error", "output_always"), ... )
rscript |
character string with the path to an R script with .r or .R extension |
rscript_log |
where to put the log, defaults in the same directory and with the same filename as |
rscript_args |
a character string with extra arguments to be passed on to Rscript |
cmd |
path to Rscript. Defaults to R_HOME/bin/Rscript |
log_append |
logical, append to the log or overwrite |
log_timestamp |
logical, indicating to append a timestamp to the script log filename in the default argument of |
workdir |
If provided, Rscript will be run from this working directory. |
type |
a character string specifying the type of command to generate:
|
... |
further arguments, specific to argument |
a character string with a command which can e.g. be put as a cronjob for running a simple R script at specific timepoints
f <- system.file(package = "cronR", "extdata", "helloworld.R") cron_rscript(f) cron_rscript(f, rscript_args = "more arguments passed on to the call") cron_rscript(f, rscript_args = c("more", "arguments", "passed", "on", "to", "the", "call")) cron_rscript(f, log_append = FALSE) cron_rscript(f, log_append = TRUE) cron_rscript(f, log_append = FALSE, log_timestamp = TRUE) ## run from home directory cron_rscript(f, workdir = normalizePath("~")) ## other non-default options for type cron_rscript(f, type = "output_on_error") cron_rscript(f, type = "output_always")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.