# Alarm Clock( )

**URL:** <https://www.ruby-forum.com/t/alarm-clock/187450>\
**Category:** Ruby\
**Created:** [April 23, 2010, 12:13pm UTC](https://www.ruby-forum.com/t/alarm-clock/187450 "2010-04-23T12:13:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vijar82](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/439d5e/32.png) [@vijar82](https://www.ruby-forum.com/u/vijar82)\
**Post date:** [April 23, 2010, 12:13pm UTC](https://www.ruby-forum.com/t/alarm-clock/187450/1 "2010-04-23T12:13:36Z")

</div>

Hi Everyone,  
I am creating an musical alarm clock e.g. play a youtube video at 5:30  
am .  
What I want is a Ruby Library\Gem where I can specify the time and I  
will have a call back at that particular time or a synchronous method  
which will wait until the set time is reached.

Any other ideas then above are also welcome.

I looked at the other posts in this forum ( and googling) and they are  
all about timers, where you do something every n secs which is not  
exactly what I want. I want to specify a particular time.

The closest I have is OpenWFEru from the good  
article([Scheduling tasks in Ruby / Rails - igvita.com](http://www.igvita.com/2007/03/29/scheduling-tasks-in-ruby-rails/))

require ‘openwfe/util/scheduler’  
include OpenWFE

scheduler = Scheduler.new  
scheduler.start

scheduler.schedule\_in(‘3d2m10s’) do  
p ‘after 3 days 2 minutes and 10 seconds stopping the scheduler and  
exiting…’  
scheduler.do\_stop  
# launch\_music\_video()  
end

I appreciate the time you take out to answer this email.

Thanks,  
Rajiv

---

<div class="post-metadata">

**Author:** ![vijar82](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/439d5e/32.png) [@vijar82](https://www.ruby-forum.com/u/vijar82)\
**Post date:** [April 23, 2010, 2:27pm UTC](https://www.ruby-forum.com/t/alarm-clock/187450/2 "2010-04-23T14:27:46Z")

</div>

Rajiv A. wrote:

> or a synchronous method  
> which will wait until the set time is reached.

That’s just sleep().

require ‘time’  
secs = Time.parse(“10pm”) - Time.now  
sleep secs
