Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding an option for a trailing argument to cron_rscript.R #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rqthomas
Copy link

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) }

@jwijffels jwijffels mentioned this pull request Jan 15, 2021
@jwijffels
Copy link
Collaborator

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

@jwijffels
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants