【发布时间】:2016-06-20 08:34:28
【问题描述】:
我有一个 R 脚本,可以生成给定时间段(1 周)的统计数据。当我从命令行运行脚本时,一切都按预期工作。但是当我尝试使用 cron 作业生成统计信息时,日期和时间函数不正确。
我的 crontab:
/usr/bin/Rscript -e "rmarkdown::render('stats.Rmd', output_file = file.path('/tmp/stats.html'))"
Rmd 文件:
---
title: "Stats"
output: html_document
---
Stats begin: `r as.Date(as.numeric(Sys.Date())-7, origin="1970-01-01")`
Stats end: `r Sys.Date()`
[...]
统计数据的开始和结束时间始终是上次执行的时间。
我已经尝试删除生成的html文件并使用--vanilla调用Rscript,但没有成功。
【问题讨论】: