execute method at a certain time

A

andy

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
 
G

Glen Holcomb

[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.
 
A

andy

Glen said:
[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
 
G

Glen Holcomb

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

Glen said:
[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?
 
A

andy

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
 
G

Glen Holcomb

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

Ah sorry, I misread needs to run all the time. Could you split that bit
hmmm, i guess so, I will look into it, thanks for the suggestion
No problem
 
G

Glen Holcomb

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

Maybe Rufus::Scheduler (

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top