I am trying to schedule a cron job via RStudio on EC2 instance.
When I use a basic script with very basic functions it works fine.
But when I want to schedule a script that contains R functions from specfic R packages, the scripts fails.
My cron looks like this:
MAILTO="myemail@adress.com"
36 * * * * /home/user1/Test_for_Cron.R
After the script is launched, I receive an email from Cron Daemon specifying something like:
Error in R_function : could not find function R_function
Execution halted
From what I found, it seems I have to specify that I want to run the script within RStudio or that I want to "source" it.
I have the feeling the answer might be in the combination of these 3 posts below but I am not finding the solution after testing out some suggestions:
Check if R is running in RStudio
Cron job for an R script failing
R command for setting working directory to source file location in Rstudio
Help much appreciated !