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

···

--
Eps

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 <eps@mailinator.com> 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 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

--
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)

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

···

--
Posted via http://www.ruby-forum.com/\.

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

···

On Thu, Apr 3, 2008 at 9:55 PM, andy <eps@mailinator.com> 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 ?

Glen Holcomb 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

···

--
Eps

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.

···

--
Eps

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

···

On Thu, Apr 3, 2008 at 2:40 PM, andy <eps@mailinator.com> wrote:

Glen Holcomb 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

--
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)

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.

···

On Fri, Apr 4, 2008 at 4:10 AM, Eps <newsgroups@epscylonb.com> wrote:

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.

--
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)

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

···

On Thu, Apr 3, 2008 at 2:55 PM, andy <eps@mailinator.com> 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

--
"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)