cronR
cronR copied to clipboard
Adding an option for a trailing argument to cron_rscript.R
Services to monitor cron jobs, like Healthchecks.io, require adding an command to the cron job command. For example,
cd '/home/rstudio/Documents/scripts/neon4cast-scoring' && /usr/local/lib/R/bin/Rscript '/home/rstudio/Documents/scripts/neon4cast-scoring/scoring.R' > '/efi_neon_challenge/log/cron/scoring.log' 2>&1 && curl -fsS -m 10 --retry 5 -o /dev/null https://hc-ping.com/1dd67f13-3a08-4a2b-86a3-6f13cb36baca
has the curl -fsS -m 10 --retry 5 -o /dev/null https://hc-ping.com/1dd67f13-3a08-4a2b-86a3-6f13cb36baca
at the end of the command. Currently, cron_rscript.R
does not support adding a command like this after part of the command that sends the R output to the log.
To support this, I added an optional argument to cron_script.R called trailing_arg
that will add the string to the end of the command - always after the log assignment.
if(!is.null(trailing_arg)){ cmd <- sprintf("%s %s %s", cmd, "&&", trailing_arg) }
Hello again,
Can you you add this solution by adding it as an extra option as the type argument to cron_rscript similar as here: https://github.com/bnosac/cronR/pull/52/files. This will allow to add other use cases as well and keeping the api rather stable.
thanks
you can use the ... argument to cron_rscript and fetch the argument in the function as in ldots <- list(...) and next do something with it in the function and document it in the ... argument