cron 作业不会 运行 在 Google Compute Engine 上的 R 脚本上

cron Job Won't Run on R Scripts on Google Compute Engine

按照这些说明,我在 Google 计算实例上安装了 R-Studio Server 运行ning:http://code.markedmondson.me/launch-rstudio-server-google-cloud-in-two-lines-r/

当我从此 RStudio-Server 打开终端时,我注意到 man、ps、vi、cron 都不存在。

bash: ps: command not found

我的目标是定期 运行 R-Script 有一个简单的 cron 作业。 我手动安装了 cron:

sudo apt-get update
sudo apt-get install cron

不过,我无法让 cron 进入 运行 这个测试:

cmd <- cron_rscript("/home/law9723/now_to_file.R")
cron_add(cmd, frequency = "*/1 * * * *", id = "now_to_file", description = "Write now to file every minute")

-显然很困惑

通过使用这些非常有用的说明,我最终得到了工作:https://yuhuisdatascienceblog.blogspot.ca/2017/07/setting-up-r-studio-server-on-google.html

对与 cron 相关的所有内容使用绝对路径名是明智的建议。

我认为当我使用此命令创建虚拟机时,Rstudio-server 所在的沙箱非常小。因此,没有 vi、man、cron、ps...

gce_vm(template = "rstudio",
             name = "my-rstudio",
             username = "mark", password = "mark1234",
             predefined_type = "n1-highmem-2")

我成功使用了 rstudio 插件。一个参考是 http://www.bnosac.be/index.php/blog/51-new-rstudio-add-in-to-schedule-r-scripts.

我也觉得你必须用

启动 cron
sudo cron start

https://cran.r-project.org/web/packages/cronR/README.html.

当我像你一样在本地使用 googleComputeEngineR 后第一次进入 GCE 上的 Rstudio 时,我安装了包 shinyFiles、miniUI 和 cronR。然后 "Schedule R scripts on Linux/Unix" 将出现在加载项列表中。