Thank you!  This is exactly what I need.

On Jan 26, 6:18 pm, Conrad Taylor <[email protected]> wrote:
> On Tue, Jan 26, 2010 at 9:07 PM, David <[email protected]> wrote:
> > You want to write a rake task that runs as a cron task every day.
>
> > lib/tasks/my_task.rake
>
> > task :touch_every_user => :environment do
> >  User.find_each {|user| user.touch }
> >  # perform some other heavy calculation and save it back to the user
> > end
>
> > For the cron task:
> > go to server, type "crontab -e"
> > 15 0* * * /path/to/rails/root rake touch_every_user
> > RAILS_ENV=production
>
> The Ruby way would be to do the following:
>
>  every :day , :at => "6:00 pm"  do
>     runner "User.all.each { |user| <do_some_work> }"
>  end
>
>  Good luck,
>
> -Conrad
>
>
>
> > On Jan 26, 8:47 pm, Vincent P <[email protected]> wrote:
> > > I have an administrative task that I need to run once a day:  I need
> > > to iterate through each user in the User table in the database, do
> > > some calculation involving some other models, and update each user
> > > record in the database.
>
> > > I am thinking about just doing it at the console (env=production).
> > > But I don't want to type all the statements again each time I carry
> > > out this task.  Is there a way to put this in a script and just run
> > > the script?
>
> > > Eventually, I'd like to schedule the task to run automatically every
> > > day, and have some sort of progress display when the task is run.
>
> > > Thanks,
>
> > > Vincent.
>
> > --
> > 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 [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<rubyonrails-talk%2Bunsubscrib 
> > [email protected]>
> > .
> > For more options, visit this group at
> >http://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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to