Execute method at a certain time

I have written a ruby script that needs to run all the time, then at a
certain time of day it needs to execute a specific method.

what is the best way of doing this ?

I could have the first script dump its data to a file all the time and
then have second script set up to run as a cron job but is there a way
to do this all in one script ?.

Thanks

How about something like this:

sleep(time_to_go - Time.now)

Of course this needs a little work to actually function but I would
think it
could work for you.

On Thu, Apr 3, 2008 at 1:55 PM, andy [email protected] wrote:


Eps


“Hey brother Christian with your high and mighty errand, Your actions
speak
so loud, I can’t hear a word you’re saying.”

-Greg Graffin (Bad Religion)

Glen H. wrote:

[Note: parts of this message were removed to make it a legal post.]

How about something like this:

sleep(time_to_go - Time.now)

it needs to do stuff inbetween the scheduled event

Ah sorry, I misread needs to run all the time. Could you split that bit off
into a separate thread?

hmmm, i guess so, I will look into it, thanks for the suggestion

On Thu, Apr 3, 2008 at 2:40 PM, andy [email protected] wrote:


Eps

Ah sorry, I misread needs to run all the time. Could you split that bit
off
into a separate thread?


“Hey brother Christian with your high and mighty errand, Your actions
speak
so loud, I can’t hear a word you’re saying.”

-Greg Graffin (Bad Religion)

andy wrote:

I have written a ruby script that needs to run all the time, then at a
certain time of day it needs to execute a specific method.

what is the best way of doing this ?

Maybe Rufus::Scheduler (
http://rufus.rubyforge.org/rufus-scheduler/files/README_txt.html ).

Regards,

Siep

On Thu, Apr 3, 2008 at 2:55 PM, andy [email protected] wrote:

Ah sorry, I misread needs to run all the time. Could you split that bit

off
into a separate thread?

hmmm, i guess so, I will look into it, thanks for the suggestion

No problem


“Hey brother Christian with your high and mighty errand, Your actions
speak
so loud, I can’t hear a word you’re saying.”

-Greg Graffin (Bad Religion)

On Thu, Apr 3, 2008 at 9:55 PM, andy [email protected] wrote:

I have written a ruby script that needs to run all the time, then at a
certain time of day it needs to execute a specific method.

what is the best way of doing this ?

I am not sure, but the Timer class from facets might help you:
http://facets.rubyforge.org/doc/api/more/classes/Timer.html

Maybe Rufus::Scheduler (
http://rufus.rubyforge.org/rufus-scheduler/files/README_txt.html ).

This looks like exactly what I need, basically cron inside ruby.

I am developing on windows at the moment and I am not sure how to
install this gem tho, does ruby gems work on windows ?.

any help appreciated.

On Fri, Apr 4, 2008 at 4:10 AM, Eps [email protected] wrote:

any help appreciated.


Eps

Rubygems works fine for me on Windows. I do all my development at work
in
Windows. However you will occasionally run across a gem that needs to
compile something, that can be trickier.


“Hey brother Christian with your high and mighty errand, Your actions
speak
so loud, I can’t hear a word you’re saying.”

-Greg Graffin (Bad Religion)