rufus-scheduler定时任务示例代码

万俟棋
2023-12-01
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

官方文档地址:http://rufus.rubyforge.org/rufus-scheduler/

转载于:https://www.cnblogs.com/zs-note/p/3777212.html

 类似资料: