How could i write, that my code sleep not for example 5 seconds, but until some time on machine is reached.
not so:
sleep(5)
but something like:
now = DateTime.Now
while now != "14:40:03"
sleep(0.5)
end
how is it correct to do?
require "time"
sleep(Time.parse("14:40:03") - Time.now)
Or use the Rufus Scheduler
https://github.com/jmettraux/rufus-scheduler
From the OpenWFEru/ruote project.
require 'rubygems'
require 'rufus-scheduler'
scheduler = Rufus::Scheduler.new
scheduler.in '20m' do
#do something
end
this provide a real passive waiting, no load.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With