每分钟安排一个 Rscript crontab [英] Schedule a Rscript crontab everyminute

查看:34
本文介绍了每分钟安排一个 Rscript crontab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于某种原因,我的 R 脚本无法使用 crontab 运行.我现在每分钟都有它用于测试,但一旦它起作用就会改变它.

For some reason my R script will not run with a crontab. I have it for every minute right now for testing, but will change it once it works.

有什么想法吗?

* * * * * Rscript "/Users/Home/Desktop/David Studios/Scraper/compiler.R"

此外,这只是终端中的普通命令.

Also, this was working as just a normal command in Terminal.

推荐答案

我可以看到可怕的smart在您的 cron 条目中引用.当您从文字处理器复制粘贴时,经常会发生这种情况.在那些令人憎恶的地方退格并重新输入正常的引号.更改:

I can see the dreaded smart quotes in your cron entry. This often happens when you copy-paste from word processors. Backspace over those abominations and re-type normal quotes. Change:

* * * * * Rscript "/Users/Home/Desktop/David Studios/Scraper/compiler.R"

* * * * * Rscript "/Users/Home/Desktop/David Studios/Scraper/compiler.R"

看到区别了吗?它很微妙,很容易被错过.

See the difference? It's subtle and easy to miss.

我看到您已经进行了上述更改,但它仍然不适合您.验证 Rscript 是否在拥有此 crontab 的用户的 $PATH 环境变量中.或者,您可以直接在 cron 条目中指定 Rscript 的完全限定路径.您可以使用以下命令在命令行上快速找到:

I see you've made the above change and it's still not working for you. Verify that Rscript is in the $PATH environment variable for the user that owns this crontab. Alternatively, you can simply specify the fully qualified path to Rscript directly in the cron entry. You can find that quickly on the command line with the following command:

which Rscript

更新 #2:

我从您的评论中看到 Rscript 的完全限定路径是 /usr/local/bin/Rscript.我猜 /usr/local/bin 不在拥有此 crontab 的用户的路径中.尝试使用完全限定的路径,如下所示:

Update #2:

I see by your comments that the fully qualified path to Rscript is /usr/local/bin/Rscript. I'm guessing /usr/local/bin is not in the path for the user who owns this crontab. Try using the fully qualified path, like this:

* * * * * /usr/local/bin/Rscript "/Users/Home/Desktop/David Studios/Scraper/compiler.R"

这篇关于每分钟安排一个 Rscript crontab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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