I have a simple Rmd document that I would like to call via a cron job using rmarkdown::render()
Here is the example.Rmd file:
---
title: "Example blah"
output: html_document
---
blah blah blah
```{r}
library(dplyr)
library(dbplyr)
library(odbc)
library(DBI)
hive_conn <- DBI::dbConnect(odbc::odbc(), dsn = "Hive")
##s3_conn <- DBI::dbConnect(noctua::athena(), s3_staging_dir = "s3://glu-athena/results/") # for sending the actual data to S3
select s,
install_dt,
split(game_name, '_')[1] as platform,
case when country = 'United States' then 1 else 0 end as usa
from device_metrics.game_install
where lower(game_name) rlike '^(?!.*QA).*' || 'fungame' || '.*'
and year || '-' || month || '-' || day = '2020-01-01'
Check the object df exists
glimpse(df)
If I run this script by clicking knit, all works as expected. A page is rendered with the expected output.
If I uncomment out the line starting with s3_conn <- ... the script also runs successfully.
However, I would like to run this script as part of a cron job. I have another script called run_for_cron.R
library(rmarkdown)
rmarkdown::render("/home/myname/Sessions/example.Rmd")
This time the cron only completes as long as the s3_conn line is commented out. If I include the s3_conn line, I see an 'execution halted' message in the cron log. This does not happen if the s3_conn is commented out.
Not sure what this signifies, it's difficult to diagnose. How can I get the document to complete when being called in a cron?