Search code examples
crongoogle-compute-enginerstudio-server

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


Following these instructions I got R-Studio Server running on a Google Compute Instance: http://code.markedmondson.me/launch-rstudio-server-google-cloud-in-two-lines-r/

When I open a terminal from this RStudio-Server I note that man, ps, vi, cron are all absent.

bash: ps: command not found

My goal is to have a simple cron job periodically run an R-Script. I manually installed cron with:

sudo apt-get update
sudo apt-get install cron

Still, I can't get cron to run this test:

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")

-Clearly Confused


Solution

  • I got things to work eventually by using these very helpful instructions: https://yuhuisdatascienceblog.blogspot.ca/2017/07/setting-up-r-studio-server-on-google.html

    Using absolute path names with everything associated with cron is sage advice.

    I think when I created a vm with this command the sandbox that Rstudio-server lives in is very minimal. Hence, no vi, man, cron, ps...

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