简体   繁体   English

cronr上的预定作业没有运行,日志读取'/ bin / sh:Rscript:command not found'

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

I am using cronr add in with RStudio (on Mac OSX 10.11.6 El Capitain) to schedule my script fetch_n_write.R. 我正在使用cronr添加RStudio(在Mac OSX 10.11.6 El Capitain上)来安排我的脚本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. 如果我从弹出的“ Schedule选项中选择“一次”,则立即运行脚本并输出它生成的文件。 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. 如果我尝试将作业安排在2分钟内每天运行,则日志显示它正在运行代码,但随后以“/ bin / sh:Rscript:command not found”结束,并且文件未写入。 No Success. 没有成功。

I am guessing after some searching that this has to do something with permissions. 经过一些搜索,我猜测这必须与权限做一些事情。 It was suggested that R might need to be reinstalled, but which R results in 有人建议 R可能需要重新安装,但which R导致
/usr/local/bin/R and which Rscript results in /usr/local/bin/Rscript which I think means I should not have to reinstall R? /usr/local/bin/Rwhich Rscript导致/usr/local/bin/Rscript我认为这意味着我不应该重新安装R?

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' ): 问题出在cron命令中,并且作业失败,因为绝对路径不用于实际命令部分(返回错误'/bin/sh: Rscript: command not found' ):

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

cron does not know where to find Rscript , so you must specify: cron不知道在哪里找到Rscript ,所以你必须指定:

19 21 * * * /usr/local/bin/Rscript /Users/ ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM