I am trying to automate running of a script (test.R) in R stored on a desktop folder (cron_test). I am using CRON in my mac terminal. The example R script generates random numbers, plots them, and saves them to a PDF:
setwd("~/Desktop/cron_test")
pdf("example_plot.pdf", width = 8, height = 8)
plot(rnorm(100))
dev.off()
My CRON code attempts to call this every minute, but nothing appears in the folder:
* * * * * Rscript /Users/username/Desktop/cron_test/test.R
Nothing is being generated. I have tried the following:
The file runs fine if I call it from the terminal, suggesting there is not an issue with the code:
Rscript /Users/username/Desktop/cron_test/test.R
I have also ensured (and double-checked) that the permissions iof the file has executable permission, as per this proposed answer to a similar issue:
chmod 777 /Users/username/Desktop/cron_test/test.R
I have also tried the other proposed solution from this answer, which is to create a shell file that calls the R script. This doesn't work, either.
I am receiving mail to state that the CRON task has run, but no output is appearing in my cron_test folder.