Neeraj Kumar
2006-Nov-04 02:59 UTC
background process (cron job) and business rules + database connection
My application needs to send email reminders to people before certain events. I think cron job is the way to go which will run every hour. Rather than putting the database connection and all the business rules in the shell script , I was wondering if there is a better way. I haven''t used rake but is it possible to write a rake job and execute it through a cron job. Any suggestions on handling these kinds of issues. 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-/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 -~----------~----~----~----~------~----~------~--~---
Philip Hallstrom
2006-Nov-04 03:12 UTC
Re: background process (cron job) and business rules + database connection
> My application needs to send email reminders to people before certain > events. I think cron job is the way to go which will run every hour. > > Rather than putting the database connection and all the business rules in > the shell script , I was wondering if there is a better way. I haven''t used > rake but is it possible to write a rake job and execute it through a cron > job. Any suggestions on handling these kinds of issues.Define a method in the appropriate model and then call it like this from cron: /path/to/rails_root/script/runner "MyModel.my_method(arg, arg)" Then you''ll have access to your db connection just like you would normally as well as all your other models, etc. -philip --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
hemant
2006-Nov-04 05:08 UTC
Re: background process (cron job) and business rules + database connection
On 11/4/06, Philip Hallstrom <rails-SUcgGwS4C16SUMMaM/qcSw@public.gmane.org> wrote:> > > My application needs to send email reminders to people before certain > > events. I think cron job is the way to go which will run every hour. > > > > Rather than putting the database connection and all the business rules in > > the shell script , I was wondering if there is a better way. I haven''t used > > rake but is it possible to write a rake job and execute it through a cron > > job. Any suggestions on handling these kinds of issues. > > Define a method in the appropriate model and then call it like this from > cron: > > /path/to/rails_root/script/runner "MyModel.my_method(arg, arg)" > > Then you''ll have access to your db connection just like you would normally > as well as all your other models, etc. > > -philip > > > >You are forgetting backgroundrb!!!! gnufied -- There was only one Road; that it was like a great river: its springs were at every doorstep, and every path was its tributary. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Neeraj Kumar
2006-Nov-04 05:22 UTC
Re: background process (cron job) and business rules + database connection
Thanks guys. I didn''t know about script/runner. I also missed out on backgrounddrb. -=- On 11/4/06, hemant <gethemant-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 11/4/06, Philip Hallstrom <rails-SUcgGwS4C16SUMMaM/qcSw@public.gmane.org> wrote: > > > > > My application needs to send email reminders to people before certain > > > events. I think cron job is the way to go which will run every hour. > > > > > > Rather than putting the database connection and all the business > rules in > > > the shell script , I was wondering if there is a better way. I haven''t > used > > > rake but is it possible to write a rake job and execute it through a > cron > > > job. Any suggestions on handling these kinds of issues. > > > > Define a method in the appropriate model and then call it like this from > > cron: > > > > /path/to/rails_root/script/runner "MyModel.my_method(arg, arg)" > > > > Then you''ll have access to your db connection just like you would > normally > > as well as all your other models, etc. > > > > -philip > > > > > > > > > You are forgetting backgroundrb!!!! > > > > gnufied > -- > There was only one Road; that it was like a great river: its springs > were at every doorstep, and every path was its tributary. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jakob Skjerning
2006-Nov-04 10:26 UTC
Re: background process (cron job) and business rules + database connection
On Nov 4, 2006, at 3:59, Neeraj Kumar wrote:> Rather than putting the database connection and all the business > rules in the shell script , I was wondering if there is a better > way. I haven''t used rake but is it possible to write a rake job and > execute it through a cron job. Any suggestions on handling these > kinds of issues.It sure is possible to run a rake command from cron. However, you can also use script/runner for this: ./script/runner "your code goes here" So for example script/runner "require ''send_reminders''" or script/ runner ''Reminder.deliver_all'' can be run from your cronjob. -- Jakob Skjerning - http://mentalized.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---