i have several tasks which i need to be executed from time to time .. some every 20 minutes and some only 1 time a day .. you know things like e.g. clearing old sessions, deleting inactive users .. how do you deal with stuff like this? cronjobs? how is your pattern for such things ... thanks in advance -- 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 -~----------~----~----~----~------~----~------~--~---
On 12/27/07, Michal Gabrukiewicz <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > i have several tasks which i need to be executed from time to time .. > some every 20 minutes and some only 1 time a day .. you know things like > e.g. clearing old sessions, deleting inactive users .. > > how do you deal with stuff like this? cronjobs? how is your pattern for > such things ... thanks in advancehttp://groups.google.com/group/rubyonrails-talk/browse_thread/thread/2d316fa75d15d03e/2f9ff335c5880f87 -- Greg Donald http://destiney.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 -~----------~----~----~----~------~----~------~--~---
thanks greg .. this helps me to solve my problems ... -- 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 -~----------~----~----~----~------~----~------~--~---
If you need to schedule recurring tasks that are related with a ruby on rails application you are building then you should go with the backgroundrb plugin for rails. You can easily schedule tasks but the best part is that the tasks will have full access to the rails environment. -- 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 too have the same issue. Can someone comment on using script/runner via a cronjob vs. using the backgroundrb method described above? Thank you, Jim --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
JimCifarelli wrote:> I too have the same issue. Can someone comment on using script/runner > via a cronjob vs. using the backgroundrb method described above? > > Thank you, > Jimyep i would appreciate this information too... -- 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 -~----------~----~----~----~------~----~------~--~---
It really depends on what you guys are trying to do. I know that is said alot but it is true. There are certain jobs where a cron job might be the best (simple jobs such as clearing the session, removing cruft, simple system stuff) Script/runner is simple but it is nice because it is built into rails. The runner script simply loads the rails environment and then executes some simple ruby code (either a simple ruby statement or a filename). On the plus side, it is the simplest choice. Some downsides are that multiple versions of the script might be running side by side which needs to be accounted for or could be pretty harmful (backgroundrb queues up tasks by default). there are certain jobs where backgroundrb daemons are the best choice (jobs where you are performing actions requiring access to the rails environment, models, library, etc) and also passing parameters or wanting tasks to queue up, etc. Tell me what you want to do and I can try to help recommend the best course of action. -- 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 -~----------~----~----~----~------~----~------~--~---
thanks for the quick comparison .. what i want to achieve is the following - i want to get rid of unused sessions - delete records of several tables where one column indicates that the record has expired - last but not least those tasks should be configurable within my application (e.g. which task to execute when) if possible Nathan Esquenazi wrote:> It really depends on what you guys are trying to do. I know that is said > alot but it is true. There are certain jobs where a cron job might be > the best (simple jobs such as clearing the session, removing cruft, > simple system stuff) > > Script/runner is simple but it is nice because it is built into rails. > The runner script simply loads the rails environment and then executes > some simple ruby code (either a simple ruby statement or a filename). > On the plus side, it is the simplest choice. Some downsides are that > multiple versions of the script might be running side by side which > needs to be accounted for or could be pretty harmful (backgroundrb > queues up tasks by default). > > there are certain jobs where backgroundrb daemons are the best choice > (jobs where you are performing actions requiring access to the rails > environment, models, library, etc) and also passing parameters or > wanting tasks to queue up, etc. > > Tell me what you want to do and I can try to help recommend the best > course of action.-- 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 -~----------~----~----~----~------~----~------~--~---
On 12/27/07, Michal Gabrukiewicz <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> - i want to get rid of unused sessionsclass ApplicationController < ActionController::Base before_filter :clean def clean ActiveRecord::Base.connection.execute( " DELETE FROM sessions WHERE NOW() - updated_at > 3600 " ) if rand( 1000 ) % 10 == 0 end end -- Greg Donald http://destiney.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 -~----------~----~----~----~------~----~------~--~---
very interesting approach ... but something like this i would rather use for smaller projects. Greg Donald wrote:> class ApplicationController < ActionController::Base > > before_filter :clean > > def clean > ActiveRecord::Base.connection.execute( " > DELETE FROM sessions > WHERE NOW() - updated_at > 3600 > " ) if rand( 1000 ) % 10 == 0 > end > > end-- 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 -~----------~----~----~----~------~----~------~--~---