`
qw232144
  • 浏览: 33959 次
  • 性别: Icon_minigender_1
社区版块
存档分类
最新评论

whenever 定时执行一个model 里面的方法

 
阅读更多

     做微信要取access_token但是access_token是有请求限制次数的,所以不能用一次取一次,access_token的有效期为2小时所以可以定时来取回access_token.

     下面是ruby里面一个定时方法。

 

whenever 安装:

gem 'whenever', :require => false #在Gamfile里面添加

 然后就是进入程序的根目录底下运行:

 wheneverize

 

这样whenever会给你初始化创建config/schedual.rb文件;
然后在该文件里面添加一下内容:

set :output, "#{path}/log/whenever.log" #设置日志输出文件
job_type :rake_no_env, "cd :path && rake :task :output" #自定义任务

every 1.day,:at=>'10:45am' do
  rake_no_env "check_daylog"    #每天早上:10:45运行 底下命令
end

 

分享到:
评论

相关推荐

    ruby中执行周期性任务(定时任务)的3种方法

    1.前言  无论是用ruby做系统管理,还是用rails做web开发,都可能遇到周期性任务,...whenever严格来说应该算一个cron的翻译器,将ruby代码翻译为cron脚本,从而将周期性任务转交给cron实际去完成。对于精通cron的shel

    C#编码规范,共享参考

    2. 一个文件应该只有一个命名空间,避免将多个命名空间放在同一个文件里面。 3. 一个文件最好不要超过500行的代码(不包括机器产生的代码)。 4. 一个方法的代码长度最好不要超过25行。 5. 避免方法中有超过5...

    R for Data Science: Import, Tidy, Transform, Visualize, and Model Data

    R for Data Science: Import, Tidy, Transform, Visualize, and Model Data ISBN: 1491910399 | 2017 | True PDF | 522 pages | 32 MB What exactly is data science? With this book, you’ll gain a clear ...

    whenever.js:对JavaScript的重新解释,每当esolang

    每当.js 适应和实施到JavaScript。 关于 与原始实现的最大区别在于,everyth.js使用函数... 这是一个无参数的函数声明(不是赋值!): function name ( ) { ... } 执行此语句后,该函数将运行。 如果您想访问全局变

    R for Data Science Visualize Model Transform Tidy and Import Data.pdf

    Whenever you measure the same thing twice, you get two results—as long as you measure precisely enough. This phenomenon creates uncertainty and opportunity. Author Garrett Grolemund, Master ...

    whenever和wherever引导的两种状语从句.doc

    whenever和wherever引导的两种状语从句.doc

    R.for.Data.Science.Visualize.Model

    Whenever you measure the same thing twice, you get two results—as long as you measure precisely enough. This phenomenon creates uncertainty and opportunity. Author Garrett Grolemund, Master ...

    mina-whenever

    Mina ::无论何时 这是的每当插件 安装 将此行添加到您的应用程序的Gemfile中: gem 'mina-whenever' 然后执行: $ bundle 或将其自己安装为: ... 该项目旨在提供一个安全,友好的合作空间,并且希

    elastic_whenever:管理ECS计划任务,例如“每时每刻”

    但是,请注意,您必须指定一个标识符。 $ elastic_whenever --help Usage: elastic_whenever [options] -i, --update identifier Clear and create scheduled tasks by schedule file -c, --clear identifier ...

    whenever:Node.js模块的require()延迟

    每当 延迟加载Node.js中的模块。 如果速度是您的事,这可能会派上用场。 例子 在同一路径上需要相对模块。 // foo.js ...您还可以传递一个数组并预加载多个模块。 var modules = whenever(['foo', 'bar

    stakecom_toynh_whenever5oo_zip_elmo_

    stake code full version as

    GA.zip_GA_forthnfm_java_whenever2ir

    Using GA to solve a function question.

    C# 编码好习惯,献给所有热爱c#的同志

    1. 避免将多个类放在一个文件里面。 2. 一个文件应该只有一个命名空间,避免将多个命名空间放在同一个文件里面。 3. 一个文件最好不要超过500行的代码(不包括机器产生的代码)。 4. 一个方法的代码长度最好不要超过...

    衍生工具的不确定性量化-研究论文

    Model and parameter uncertainties are ubiquitous whenever a parametric model is selected to value a derivative instrument. 结合蒙特卡罗方法和Smolyak插值算法,本文提出了一种准确有效的数值方法来量化复杂...

    alamgirfiles.zip_is proposed power_non linear load_power control

    The battery will charge whenever the renewable energy power is greater than to consumer load power as well as the battery will discharge whenever the renewable energy power is lesser than to consumer...

    glm-master.zip

    GLM emulates GLSL's approach to vector/matrix operations whenever possible. To use GLM, include glm/glm.hpp. Example from GLM manual: #include int foo() { glm::vec4 Position = glm::vec4( glm::vec3...

    C#编码好习惯小结

    1. 避免将多个类放在一个文件里面。 2. 一个文件应该只有一个命名空间,避免将多个命名空间放在同一个文件里面。 3. 一个文件最好不要超过500行的代码(不包括机器产生的代码)。 4. 一个方法的代码长度最好...

    regression model for categorical and limited dependent variables Scott Long

    研究回归分析的必读宝典. A unified treatment of the most useful models for categorical and limited ... In addition, the author explains how models relate to linear regression models whenever possible.

    ruby执行周期性任务的三种gem介绍

    whenever严格来说应该算一个cron的翻译器,将ruby代码翻译为cron脚本,从而将周期性任务转交给cron实际去完成。对于精通cron的shell程序员来说可能不值一提,但对rubyist却不是。首先,我们可以使用ruby语言来书写...

    计划任务Cron表达式生成

    计划任务,是任务在约定的时间执行已经计划好的工作,这是表面的意思

Global site tag (gtag.js) - Google Analytics