Scheduled tasks on rails

How do you set up automated tasks on rails. Say I wanted to send an
update mailing every night at midnight to my users, or every night
connect to a external database to update information on my database?

Hi,

How do you set up automated tasks on rails. Say I wanted to send an
update mailing every night at midnight to my users, or every night
connect to a external database to update information on my database?

you can write a rake task and then invoke it with a cron-like tool
(depending on your OS and preferences)

writing rake tasks is pretty straight-forward. In your rails directory
there are a lot of tasks you can take a look for getting the flavour of
it. They are under vendor/rails/railties/lib/tasks

regards,

javier ramírez

Check out this great tutorial on using Rake for tasks

On Aug 10, 2:30 pm, Scott Pn [email protected] wrote:

How do you set up automated tasks on rails. Say I wanted to send an
update mailing every night at midnight to my users, or every night
connect to a external database to update information on my database?

Posted viahttp://www.ruby-forum.com/.

Check out this great Rake tutorial:
http://www.railsenvy.com/2007/6/11/ruby-on-rails-rake-tutorial

On Aug 10, 12:30 pm, Scott Pn [email protected]
wrote:

How do you set up automated tasks on rails. Say I wanted to send an
update mailing every night at midnight to my users, or every night
connect to a external database to update information on my database?

Posted viahttp://www.ruby-forum.com/.

I usually do something pretty simple: I create a class in the vendor
directory, and then setup a cron job to run script\runner with that
file. For example:

I have a file called session_cleaner.rb in \vendor like this:

class SessionCleaner
CGI::Session::ActiveRecordStore::Session.destroy_all( [‘updated_at
< ?’, 240.minutes.ago] )
end

Then I have a cron job that runs:

ruby script\runner SessionCleaner -e production

I’ve also used this method for nightly emails to process new user
signups, etc.

Dave
http://www.gotossh.com - web based SSH
http://www.stevensonsoftware.com - affordable VPS hosting