使用cron调度R脚本 [英] Schedule R script using cron

查看:142
本文介绍了使用cron调度R脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用cron安排我的R脚本,但它不工作。看来R不能在cron中找到包。任何人都可以帮助我?

 #source my profile 
。 /home/winie/.profile
#script.R将加载包
R CMD BATCH /home/script.R

解决方案

考虑这些提示


  1. 使用Rscript(或littler)而不是 R CMD BATCH


  2. <


  3. 确保脚本自行运行

  4. $ b $

    b
  5. 在详细模式中测试几次


a href =http://dirk.eddelbuettel.com/cranberries/> CRANberries 通过cronjob调用R脚本
(我通过littler ,但Rscript
也应该工作)。为此,我的Ubuntu服务器上 / etc / crontab 中的条目是

 #每几个小时,跑小红莓
16 * / 3 * * * edd cd / home / edd / cranberries&& ./cranberries.r

,因此每三个小时过去十六分钟,一个shell命令正在运行我的身份。它改变成工作目录,并调用R脚本(具有可执行模式等)。



看看这个,我实际上可以运行脚本,并且 setwd()中的命令....


I am trying to schedule my R script using cron, but it is not working. It seems R can not find packages in cron. Anyone can help me? Thanks.

The following is my bash script

# source  my profile
. /home/winie/.profile
# script.R will load packages
R CMD BATCH /home/script.R 

解决方案

Consider these tips

  1. Use Rscript (or littler) rather than R CMD BATCH

  2. Make sure the cron job is running as you

  3. Make sure the script runs by itself

  4. Test it a few times in verbose mode

My box is running the somewhat visible CRANberries via a cronjob calling an R script (which I execute via littler but Rscript should work just as well). For this, the entry in /etc/crontab on my Ubuntu server is

# every few hours, run cranberries
16 */3 * * *    edd     cd /home/edd/cranberries && ./cranberries.r

so every sixteen minutes past every third hour, a shell command is being run with my id. It changes into the working directory, and call the R script (which has executable modes etc).

Looking at this, I could actually just run the script and have setwd() command in it....

这篇关于使用cron调度R脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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