Heroku Cron无法运行

| 因此,我在heroku上运行了一个简单的cron任务。但是,它不起作用。我一直在日志中得到这个:
2011-06-15T03:21:35+00:00 heroku[web.1]: State changed from up to bouncing
2011-06-15T03:21:35+00:00 heroku[web.1]: State changed from created to starting
2011-06-15T03:21:35+00:00 heroku[slugc]: Slug compilation finished
2011-06-15T03:21:41+00:00 heroku[web.1]: Starting process with command: `thin -p 5926 -e production -R /home/heroku_rack/heroku.ru start`
2011-06-15T03:21:46+00:00 app[web.1]: >> Thin web server (v1.2.6 codename Crazy Delicious)
2011-06-15T03:21:46+00:00 app[web.1]: >> Maximum connections set to 1024
2011-06-15T03:21:46+00:00 app[web.1]: >> Listening on 0.0.0.0:5926, CTRL+C to stop
2011-06-15T03:21:47+00:00 heroku[web.1]: State changed from starting to up
2011-06-15T03:22:30+00:00 heroku[web.1]: Stopping process with SIGTERM
2011-06-15T03:22:30+00:00 app[web.1]: >> Stopping ...
2011-06-15T03:22:30+00:00 heroku[web.1]: Process exited
我的cron.rake文件(每4小时才放一次)
 desc \"This task is called by the Heroku cron add-on\"
 task :cron => :environment do
   if Time.now.hour % 4 == 0 # run every four hours
     puts \"Sending email of most popular post.\"
     puts \"done.\"
   end
 end
不知道为什么它不会只做推杆。另外,一旦这起作用了,我想经常从我的模型中调用函数。如果我的模型是Micropost,而函数是has_fun,我可以用cron.rake中的Micropost.has_fun来调用它吗? 任何帮助将不胜感激。堆栈溢出的人员对我学习Rails来说是不可思议的帮助。再次感谢。 更新: 我将看跌期权更改为:
UserMailer.registration_confirmation().deliver
但是,这将导致相同的日志输出。我已经使用actionmailer多次测试了registration_confirmation电子邮件,它们可以与上述功能一起使用。 (电子邮件在user_mailer.rb中编码为静态。     
已邀请:
        您应该尝试rufus Scheduler: 安装宝石
 gem install rufus-scheduler
确保将宝石包括在捆绑器中,或者将其包括在内。 然后,您需要创建一个名为
task_scheduler.rb
的文件,并将其粘贴到
initializers
目录中。
 require \'rufus/scheduler\'
 scheduler = Rufus::Scheduler.start_new

 scheduler.every \'10m\' do

      puts \"Test!\"      
      #do something here

 end
如果您有任何问题,可以查看此博客文章: http://intridea.com/2009/2/13/dead-simple-task-scheduling-in-rails?blog=company     
        Thoughtbot不久前发表了一篇博客文章,概述了使用RSpec,Timecop和Bourne在本地测试Heroku cron作业的方法。     

要回复问题请先登录注册