rails 計劃任務 定時執行 外掛程式

來源:互聯網
上載者:User

最近要在redmine上實現周報的定時統計與發送的功能,這就不可避免地要用到rails的計劃任務功能,上網搜了一下,發現了這幾個外掛程式,這裡稍微列舉一下,僅供參考:

1、BackgrounDRb

官網:http://backgroundrb.rubyforge.org/

這款外掛程式其實最主要的功能是讓rails應用把處理時間長的操作放到背景進程中去執行,以避免前端使用者的等待。至於它能不能執行計畫任務,網上說了很多意見。

http://www.javaeye.com/topic/149342

官網中提到:

==============

Invoking Tasks

Task charge_customer defined in BillingWorker can be invoked in several ways. To beging with it can be invoked from rails or can be scheduled to execute at particular interval using cron like syntax.

==============

BackgrounDRb可以有多種方式來調用這些已定義好的Worker(指任務的執行器),包括①在rails中調用;②使用類似於cron(linux下的一個計劃任務程式)文法在指定時間間隔運行

但是好像並不能在指定的時間點運行。

2、rufus-scheduler

官網:http://rufus.rubyforge.org/rufus-scheduler/

官網上的簡介:

==============

rufus-scheduler is a Ruby gem for scheduling pieces of code (jobs). It understands running a job AT a certain time, IN a certain time, EVERY x time or simply via a CRON statement.

rufus-scheduler is no replacement for cron/at since it runs inside of Ruby.

==============

最迷人的幾點就是:可以在指定的①時間點②時間段③時間間隔,執行指定的作業。

另外一個部落格上的簡介:http://hi.baidu.com/ma95221/blog/item/cec152c4a7e782a08326ace1.html

3、RailsCron

官網:好像沒有官網更新了

我是在這裡看到它的:http://hlee.javaeye.com/blog/438511

網址裡面有對它用法的簡介。在評論中,也有一位仁兄提到了RailsCron的一些問題,包括它本來的作者也推薦大家別用RailsCron而改用BackgrounDRb或daemon_generator了。

4、daemon_generator

作者部落格:http://kylemaxwell.typepad.com/everystudent/2006/08/after_writing_r.html

我是在這裡看到它的:http://douglasfshearer.com/blog/cron-jobs-in-ruby-on-rails(是一個外國網站)

在網站中有對它的使用方法進行講解。

看上去也不錯,不過好像找不到它的下載連結。o(╯□╰)o

 

綜上所述,個人覺得還是第二個外掛程式refus-scheduler比較符合我的需求,而且是一個能夠下載的版本(使用gem)。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.