Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scheduled job on cronr not running, log reads '/bin/sh: Rscript: command not found'

Tags:

bash

macos

r

I am using cronr add in with RStudio (on Mac OSX 10.11.6 El Capitain) to schedule my script fetch_n_write.R.

If I select 'Once' from the Schedule options in the pop up, the script is run immediately and the file it generates is outputted. Success!

If I try to schedule the job to run daily in 2 minutes, the log shows it running the code but then ends with '/bin/sh: Rscript: command not found' and the file does not get written. No Success.

I am guessing after some searching that this has to do something with permissions. It was suggestedthat R might need to be reinstalled, but which R results in
/usr/local/bin/R and which Rscriptresults in /usr/local/bin/Rscript which I think means I should not have to reinstall R?

like image 808
Scott Avatar asked Jan 24 '17 04:01

Scott


1 Answers

The problem is in the cron command, and the job fails because the absolute path is not used for the actual command portion (returning the error '/bin/sh: Rscript: command not found'):

19 21 * * * Rscript /Users/ ... 

cron does not know where to find Rscript, so you must specify:

19 21 * * * /usr/local/bin/Rscript /Users/ ...
like image 174
l'L'l Avatar answered Oct 06 '22 00:10

l'L'l