How to set up a cron job to run R scripts

  • Answered
I have recently installed R(a free statistical software) with the help of inmotion hosting support center in my vps and was trying to setup a cron job to run a R script. But it doesn't work.

If I run the same command from the command prompt it works. I have tried both the commands below but the cron job fails

cd ./path_to_R_script; R CMD BATCH script.R

cd ./path_to_R_script; Rscript script.R
Hi somdeb,

When your cron job fails, does it give you an error message? If so, please post a comment at the bottom of this page with the full error message as that will help troubleshoot what may be causing the problem.

I can't say for sure if the path you're using is correct, but I would recommend trying to use the full path to your script, such as /home/userna5/path/to/script

Any further details / error messages you can provide will help us quite a bit with resolving the cron that you have setup.

- Brad