我想尝试从运行为Cron作业的bash脚本中渲染R markdown文件中的html内容,但除了作为Cron作业运行时,一切都正常,我不知道原因。我的做法如下:
我的脚本是来自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.
这个脚本在Rstudio中没有问题。
接下来,我尝试从终端运行一个Rmd脚本:
Rscript -e "require( 'rmarkdown' ); render('/home/sms/Dokumenty/R/test.Rmd', 'html_document')"
没有任何问题。它可以正常工作。
因此,我创建了Bash脚本。
#!/bin/bash
Rscript -e“require('rmarkdown'); render('/home/sms/Dokumenty/R/test.Rmd','html_document')”
并且更改了chmod 755 test.sh
同样可以完美运行。
但是当放入Cron文件中(管理员和用户),就会出现问题:
28 18 * * * sh /home/sms/Dokumenty/R/test.sh
它不起作用
有什么想法我做错了什么吗?