andy
April 3, 2008, 9:56pm
#1
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
andy
April 3, 2008, 10:26pm
#2
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)
andy
April 3, 2008, 10:40pm
#3
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
andy
April 3, 2008, 10:55pm
#4
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
andy
April 3, 2008, 10:46pm
#5
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
April 3, 2008, 11:44pm
#6
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
andy
April 3, 2008, 11:05pm
#7
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)
andy
April 3, 2008, 11:53pm
#8
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
andy
April 4, 2008, 12:10pm
#9
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.
andy
April 4, 2008, 6:04pm
#10
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)