[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

execute method at a certain time

Eps

4/3/2008 7:53:00 PM

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
9 Answers

Glen Holcomb

4/3/2008 8:26:00 PM

0

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

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)

Eps

4/3/2008 8:37:00 PM

0

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

Glen Holcomb

4/3/2008 8:44:00 PM

0

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

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

Eps

4/3/2008 8:53:00 PM

0


> 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

Glen Holcomb

4/3/2008 9:04:00 PM

0

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

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

Siep Korteling

4/3/2008 9:44:00 PM

0

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/READM... ).

Regards,

Siep
--
Posted via http://www.ruby-....

Thomas Wieczorek

4/3/2008 9:52:00 PM

0

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

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

Eps

4/4/2008 10:05:00 AM

0


> Maybe Rufus::Scheduler (
> http://rufus.rubyforge.org/rufus-scheduler/files/READM... ).

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

Glen Holcomb

4/4/2008 4:04:00 PM

0

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

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

>
> Maybe Rufus::Scheduler (
> > http://rufus.rubyforge.org/rufus-scheduler/files/READM... ).
> >
>
> 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
>
>
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)