做微信要取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