source: subversion/sites/rails_port_branches/notesapi/script/cleanup @ 7300

Last change on this file since 7300 was 4310, checked in by tomhughes, 12 years ago

Replace the old session cleanup daemon with a new script to be run from
cron periodically.

  • Property svn:executable set to *
File size: 477 bytes
Line 
1#!/usr/bin/env ruby
2
3require File.dirname(__FILE__) + '/../config/environment'
4
5Session.find(:all, :conditions => ["updated_at < ?", 1.week.ago]).each do |session|
6  begin
7    if session[:user] and User.find(session[:user])
8      session.destroy if session.updated_at < 1.month.ago
9    else
10      session.destroy
11    end
12  rescue Exception => ex
13    puts "Invalid session #{session.session_id}: #{ex.to_s}"
14    session.destroy
15  end
16end
17
18UserToken.delete_all("expiry < NOW()")
Note: See TracBrowser for help on using the repository browser.