[root@17_johnson]# cat current/lib/clear_sessions_data.rb
require 'rubygems'
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => "mysql",
:host => "localhost",
:username => "root",
:password =>"tm#secure",
:database => "tm_production",
:socket => "/var/lib/mysql/mysql.sock"
)
sql = 'DELETE FROM sessions WHERE updated_at < DATE_SUB(NOW(), INTERVAL 1 DAY);'
ActiveRecord::Base.connection.execute(sql)
------------------
NOTE # Set script As cron at Every day 12.00 AM.
require 'rubygems'
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => "mysql",
:host => "localhost",
:username => "root",
:password =>"tm#secure",
:database => "tm_production",
:socket => "/var/lib/mysql/mysql.sock"
)
sql = 'DELETE FROM sessions WHERE updated_at < DATE_SUB(NOW(), INTERVAL 1 DAY);'
ActiveRecord::Base.connection.execute(sql)
------------------
NOTE # Set script As cron at Every day 12.00 AM.
1 comments:
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
Devops Training in electronic city
Post a Comment