Skip to content

Instantly share code, notes, and snippets.

@khamanaka
Created February 12, 2009 01:37
Show Gist options
  • Save khamanaka/62429 to your computer and use it in GitHub Desktop.
Save khamanaka/62429 to your computer and use it in GitHub Desktop.
#!/usr/bin/ ruby
RAILS_ENV ||= "production"
require File.dirname(__FILE__) + '/../config/boot'
require RAILS_ROOT + '/config/environment'
con = ActiveRecord::Base.connection
con.execute "DELETE FROM sessions WHERE updated_at < '#{14.days.ago.to_s(:db)}'"
con.tables.each do |table|
con.execute "OPTIMIZE TABLE #{table}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment