I am writing a rails script that I need to run continuosly. It basiclly scans the a particular table in my DB and makes queries to an outside service and updates the table as needed. I would like to keep the script constatnly running run. If I write the script as a runner, is there a way to do this? Thanks! -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
By continuously do you mean ''scan table, scan table, scan table ...'' or ''scan table, wait for 10 minutes, repeat'' If it is the latter then you could simply set up a cron job to run every few minutes. Here''s some details on how you might do it http://peter-hickman.blogspot.com/2009/09/rake-task-to-install-crons.html http://peter-hickman.blogspot.com/2009/11/crons-for-rails.html This sort of thing occurs a few times in my blog. Hope it might be of help. Of course this assumes that you are running on *nix or OSX -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Actually, I am interested in the former. That is, scan table and once it is done start form the top again and scan again without any delay. Thanks for the resource. On Apr 21, 8:25 am, Peter Hickman <peterhickman...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> By continuously do you mean ''scan table, scan table, scan table ...'' or > ''scan table, wait for 10 minutes, repeat'' > > If it is the latter then you could simply set up a cron job to run every few > minutes. > > Here''s some details on how you might do it > > http://peter-hickman.blogspot.com/2009/09/rake-task-to-install-crons.... > > http://peter-hickman.blogspot.com/2009/11/crons-for-rails.html > > This sort of thing occurs a few times in my blog. > > Hope it might be of help. > > Of course this assumes that you are running on *nix or OSX > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Apr 21, 7:17 am, "tashfeen.ekram" <tashfeen.ek...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Actually, I am interested in the former. That is, scan table and once > it is done start form the top again and scan again without any delay.http://cr.yp.to/daemontools.html should help (on Unix). Your Ruby script has an endless loop. daemontools comes in to start it initially, or if the script fails, or for you to start/stop . Stephan> Thanks for the resource. > > On Apr 21, 8:25 am, Peter Hickman <peterhickman...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > wrote: > > > > > By continuously do you mean ''scan table, scan table, scan table ...'' or > > ''scan table, wait for 10 minutes, repeat'' > > > If it is the latter then you could simply set up a cron job to run every few > > minutes. > > > Here''s some details on how you might do it > > >http://peter-hickman.blogspot.com/2009/09/rake-task-to-install-crons.... > > >http://peter-hickman.blogspot.com/2009/11/crons-for-rails.html > > > This sort of thing occurs a few times in my blog. > > > Hope it might be of help. > > > Of course this assumes that you are running on *nix or OSX > > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks! I can think of a few ways to write a script with a continous loop. Just wondering though if there is a straight forward way to do it. The one way I can think of is to have a integer that is the index of the record in the DB and then just reset it when it hits the number of records in the DB. On Apr 21, 11:00 am, Stephan Wehner <stephanweh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Apr 21, 7:17 am, "tashfeen.ekram" <tashfeen.ek...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Actually, I am interested in the former. That is, scan table and once > > it is done start form the top again and scan again without any delay. > > http://cr.yp.to/daemontools.htmlshould help (on Unix). > > Your Ruby script has an endless loop. daemontools comes in to start it > initially, or if the script fails, or for you to start/stop . > > Stephan > > > > > > > Thanks for the resource. > > > On Apr 21, 8:25 am, Peter Hickman <peterhickman...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > > wrote: > > > > By continuously do you mean ''scan table, scan table, scan table ...'' or > > > ''scan table, wait for 10 minutes, repeat'' > > > > If it is the latter then you could simply set up a cron job to run every few > > > minutes. > > > > Here''s some details on how you might do it > > > >http://peter-hickman.blogspot.com/2009/09/rake-task-to-install-crons.... > > > >http://peter-hickman.blogspot.com/2009/11/crons-for-rails.html > > > > This sort of thing occurs a few times in my blog. > > > > Hope it might be of help. > > > > Of course this assumes that you are running on *nix or OSX > > > > -- > > > 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-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm. > > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. > > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.- Hide quoted text - > > - Show quoted text --- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 6 May 2010 18:51, tashfeen.ekram <tashfeen.ekram-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks! > > I can think of a few ways to write a script with a continous loop. > Just wondering though if there is a straight forward way to do it.while true Model.all.each do |record| #... stuff with record end end Writing a continuous loop isn''t hard (I do it myself by mistake all the time!) - but monitoring it to ensure it''s running is the problem. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.