I am having problems when trying to run my R script using Rscript via crontab.
The following command works fine when running in the command line
Rscript /var/www/html/sent/sentiment/code/parse.r
But the following line inside crontab
*/5 * * * * Rscript /var/www/html/sent/sentiment/code/parse.r > /var/www/html/sent/sentiment/code/backup.log 2>&1
Will return the following error in the log
Error in library(twitteR) : there is no package called 'twitteR'
Execution halted
Why is it possible that Rscript won’t be able to find the packages when running using cron?
How can I make crontab ‘see’ my R packages.
Any tip much appreciated.
As suggested in the comments, the problem might be that you and your crontab are using a different R install.
To check if it is the case, run
which Rscriptas yourself and as crontab.If they are different (which I suspect), you could use the full path to the appropriate
Rscriptwhen you are calling it from crontab. A more permanent solution would require setting environment variables.