I might have answered my own question. I just took the necessary pieces out
of the environment.rb and put it in a script file as such:
#!/usr/bin/ruby
#establish root dir
RAILS_ROOT = File.dirname(__FILE__) + "/../"
RAILS_ENV = ENV[''RAILS_ENV''] ||
''development''
#include active record
require ''active_record''
#load config
ActiveRecord::Base.configurations
File.open("#{RAILS_ROOT}/config/database.yml")
{ |f| YAML::load(f) }
ActiveRecord::Base.establish_connection
#clear sessions
ActiveRecord::Base.connection.execute("delete from sessions where (INTERVAL
30 MINUTE + updated_at)<utc_timestamp();")
On 9/15/05, Matt Pantana
<matt.pantana-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> I''m storing my session in a mysql database and want to clear them
out when
> they''ve not be updated for 20 minutes. I''m using the
following method
> ./script/runner ''Session.clean_up''
> protected
> def self.clean_up
> ActiveRecord::Base.connection.execute("delete from sessions where
> (INTERVAL 20 MINUTE + updated_at)<utc_timestamp();")
> end
> This works fine, however, cpu utilization spikes everytime the runner
> script has to load the full environment. Since this is such a basic sql
> statement, is there a better way to accomplish this.
> Also, I don''t want to rule out the runner script completely b/c
at times,
> I need to send email notifications as well. As I need to check on a fairly
> regular basis if there is any activity to take, I''m wondering if I
can avoid
> the cost of loading up the environment every time when mostly there will be
> no action to take.
>
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails