Running a bash script as a Cron job with R Markdown

I want to try rendering html from an R markdown file, but from a bash script that runs as Cron jobs. I don’t know why everything is working fine, except for working in Cron. What am I doing:

My script is a demo of a script from Rstudio

---
title: "test"
author: "sms"
date: "24 maja 2015"
output: html_document
---

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

```{r}
summary(cars)
```
etc.

This script works without problems in Rstudio.

Next, I try to run the Rmd script from the terminal:

Rscript -e "require( 'rmarkdown' ); render('/home/sms/Dokumenty/R/test.Rmd', 'html_document')"

There were no problems. He works.

So I am creating a bash script

#!/bin/bash

Rscript -e "require ('rmarkdown'); render ('/home/sms/Dokumenty/R/test.Rmd', 'html_document')"

and modified by chmod 755 test.sh

Also works as charme.

But if you put in the Cron file (admin and user):

28 18 * * * sh /home/sms/Dokumenty/R/test.sh

Does not work

Any idea what I'm doing wrong?

+4
source share
3

.   , Rscript root, Rscript souza, .   , crontab souza "sudo crontab -u souza -e", Rscript souza, root.  

+1

, , .

-, Rscript, , renderTest.R

#!/usr/bin/Rscript
library(rmarkdown)
setwd("/home/sms/Dokuments/R")
render("test.Rmd")   # I usually use default arguments

-, script (chmod 0755 renderTest.R).

-, script. , cron , .

-, cronjob, .

, : Documents/ not Documenty/.

+1

.

, knitr:: knit2html rmarkdown:: render

,

+1

All Articles