rails中做定时任务的程序包 - rufus-scheduler
fmms
13年前
<p>rufus-scheduler 是一个简简单单在rails中做定时任务的程序包,基本上可以解决我们日常中的定时任务,rufus-scheduler当然也支持某个时间点做某事,某个时间段做某事等等</p> <p>安装方法:gem install rufus-scheduler</p> <p>示例代码:</p> <pre class="brush:ruby; toolbar: true; auto-links: false;"> require 'rubygems' require 'rufus/scheduler' scheduler = Rufus::Scheduler.start_new scheduler.in '20m' do puts "order ristretto" end scheduler.at 'Thu Mar 26 07:31:43 +0900 2009' do puts 'order pizza' end scheduler.cron '0 22 * * 1-5' do # every day of the week at 22:00 (10pm) puts 'activate security system' end scheduler.every '5m' do puts 'check blood pressure' end</pre> <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1327499250890" target="_blank">http://www.open-open.com/lib/view/home/1327499250890</a></p> <p></p>