delay_job 位于 http://github.com/collectiveidea/delayed_job
delay_job 有能力做cron任务吗?比如每晚凌晨 1 点运行一个脚本。或者每 1 小时运行一个脚本。
如果没有,有什么合适的 gem 可以做到这一点?是否可以使用浏览器进行远程监控,并记录成功和错误?
最佳答案
我参与了一个尝试使用 DelayedJob 来安排 future 项目的项目。它糟透了。
相反,我建议您使用 每当 gem :
http://github.com/javan/whenever
Whenever is a Ruby gem that provides a clear syntax for defining cron jobs. It outputs valid cron syntax and can even write your crontab file for you. It is designed to work well with Rails applications and can be deployed with Capistrano. Whenever works fine independently as well.
代码看起来像这样(来自 github)
every 3.hours do
runner "MyModel.some_process"
rake "my:rake:task"
command "/usr/bin/my_great_command"
end
every 1.day, :at => '4:30 am' do
runner "MyModel.task_to_run_at_four_thirty_in_the_morning"
end
every :hour do # Many shortcuts available: :hour, :day, :month, :year, :reboot
runner "SomeModel.ladeeda"
end
every :sunday, :at => '12pm' do # Use any day of the week or :weekend, :weekday
runner "Task.do_something_great"
end
Here是关于如何使用它的 RailsCast 视频。
和相应的ASCIICast .
关于ruby-on-rails - Rails 的 "delayed_job"真的用于 cron 任务吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3632129/