I have a background code with backgroundfu: # Simple, non-monitored worker. class ReportWorker def add() Report.generate_rep() end end I want this code only to run on Fridays and only to run one time every Friday. How can I do that? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
John Smith wrote:> I have a background code with backgroundfu: > > # Simple, non-monitored worker. > class ReportWorker > > > def add() > Report.generate_rep() > end > > end > > I want this code only to run on Fridays and only to run one time every > Friday. How can I do that?Sounds like a job for cron and script/runner. Or even cron and a rake task. Doesn''t sound like you need any kind of "background" functionality. That would seem like overkill. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
How about some kind of loop? Why using cron? Is it the best option? I have backgroundfu working. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I don''t think backgroundFu is for scheduled tasks. If you use backgroundrb, though, you can just do this: class HelloWorker < BackgrounDRb::MetaWorker set_worker_name :hello_worker def create(args = nil) # time argument is in seconds add_periodic_timer(604800) { expire_sessions } end def expire_sessions # expire user sessions end end or if you want a more precise scheduling, use can use cron or the unix scheduler through backgroundrb http://backgroundrb.rubyforge.org/scheduling/index.html -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Nathan Esquenazi wrote:> I don''t think backgroundFu is for scheduled tasks. If you use > backgroundrb, though, you can just do this: > > class HelloWorker < BackgrounDRb::MetaWorker > set_worker_name :hello_worker > > def create(args = nil) > # time argument is in seconds > add_periodic_timer(604800) { expire_sessions } > end > > def expire_sessions > # expire user sessions > end > end > > or if you want a more precise scheduling, use can use cron or the unix > scheduler through backgroundrb > > http://backgroundrb.rubyforge.org/scheduling/index.htmlFor now, what I have done is some kink of loop with Backgroundfu. It seems not to use a lot of CPU but I have to test it for some time. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---