Back

定时执行的几个GEM比较( comparison of scheduled-task gems )

发布时间: 2013-04-28 00:16:00

delayed_jobs: 可以延后执行一个任务。最常见的: 发送EMAIL。( it is used for one-off tasks, classic example: sending emails)

whenever: 可读性极强的 crontab.   需要配合具有crontab的操作系统来使用   ( fits for those OS with crontab supported. ) 

rufu-scheduler: 可以定时执行N次,也可以延后执行一次,可以看成是 delayed_job + whenever的混合版。 ( supports both recurring task and one-off tasks. ) 

resque-scheduler: 需要跟redis配合使用的东东。没用过。看了说明,跟delayed_job 几乎一样的。 离不开redis是它最大的“特点”。比较有意思的是,提供了一个WEB UI. (不过我认为专业程序员 有console就足够了)  ( lives on Redis DB, also with a fancy WEB UI which is useless for professional programmers) 

clockwork: 也看了下,跟delayed_job, resque-scheduler 几乎一样的。  (almost the same with delayed_job, resque-scheduler ) 

clockwork 和其他。。。比较全的对比见:https://www.ruby-toolbox.com/categories/scheduling

每个gem都有自己针对的一面。所以根据现在项目的需求(要配置一个可以定时抓取视频的应用,需要可以随时开始,随时停止),看过前面3个之后,我决定选择rufu-scheduler 。它不但可以满足 one-off task,  也满足recurring task. 呵呵, 最重要的是,可以随时同过ruby 代码来控制停止和开启。(而不是通过命令行的形式)) ,就它了。   ( considering the manually start/stop by ruby code but not the console, I decided to choose rufu-scheduler to do the job. ) 

Back