3 require File.dirname(__FILE__) + '/../config/environment'
8 sessions = Session.find(:all,
9 :conditions => ["updated_at < ? and id > ?", 1.week.ago, last_session_id],
10 :order => :id, :limit => 1000)
12 sessions.each do |session|
13 last_session_id = session.id
16 if session[:user] and User.find(session[:user])
17 session.destroy if session.updated_at < 1.month.ago
21 rescue Exception => ex
22 puts "Invalid session #{session.session_id}: #{ex.to_s}"
26 end while sessions.length > 0
28 UserToken.delete_all("expiry < NOW()")