如何在 crontab 中运行 R 脚本 [英] How to run an R script in crontab

查看:26
本文介绍了如何在 crontab 中运行 R 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 crontab -e 我试过:

Using crontab -e I've tried:

* * * * *  Rscript /home/.../file.r
* * * * * /usr/lib/R/bin/Rscript /home/.../file.r
* * * * * /usr/bin/Rscript /home/.../file.r
* * * * * /home/.../foo.sh

其中 foo.sh 包含:

where foo.sh contains:

sudo R CMD BATCH file.r

只需运行 $ ./foo.sh 即可.$ R CMD BATCH file.r 有效.

Just running $ ./foo.sh works. $ R CMD BATCH file.r works.

我在 crontab 中没有尝试过任何工作.有什么想法吗?

Nothing I've tried in crontab works. Any ideas?

推荐答案

您需要在 foo.sh 中包含完整路径:

You'll need to have the full path in your foo.sh:

sudo R CMD BATCH /home/.../file.r

我还应该补充一点,第一个版本对我有用,尽管我将其设置为特定时间而不是 * * * * *

I should also add that the first version worked for me, although I set it to a specific time rather than * * * * *

这篇关于如何在 crontab 中运行 R 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆