<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Laughing Meme &#187; cron</title>
	<atom:link href="http://laughingmeme.org/tag/cron/feed/" rel="self" type="application/rss+xml" />
	<link>http://laughingmeme.org</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 29 Jan 2012 21:54:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Flushing Rails Database (MySQL) Sessions</title>
		<link>http://laughingmeme.org/2005/12/07/flushing-rails-database-mysql-sessions/</link>
		<comments>http://laughingmeme.org/2005/12/07/flushing-rails-database-mysql-sessions/#comments</comments>
		<pubDate>Wed, 07 Dec 2005 21:40:00 +0000</pubDate>
		<dc:creator>Kellan</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[typo]]></category>

		<guid isPermaLink="false">http://lm.quxx.info/?p=3146</guid>
		<description><![CDATA[I use Rails&#8217; database session backend for LM. (for login, as well as &#8220;flash&#8221;) Without any sort of built in garbage collection the sessions table gets very large, very quickly. Beyond aesthetic issues, this can also cause MySQL&#8217;s key buffer to fill up. (which on Debian is by default set quite low) So I wrote [...]]]></description>
			<content:encoded><![CDATA[<p>I use Rails&#8217; <a href="http://wiki.rubyonrails.com/rails/pages/HowtoChangeSessionStore">database session backend</a> for <a href="http://laughingmeme.org">LM</a>. (for login, as well as <a href="http://api.rubyonrails.com/classes/ActionController/Flash.html">&#8220;flash&#8221;</a>)  Without any sort of built in garbage collection the sessions table gets <strong>very</strong> large, very quickly.  Beyond aesthetic issues, this can also cause MySQL&#8217;s key buffer to fill up. (which on Debian is by default set quite low)</p>

<p>So I wrote up a quick flush method, and saved it in a file <code>models/session.rb</code>.</p>

<pre><code>class CGI::Session::ActiveRecordStore::Session
  def self.flush_old_empty_sessions
     self.delete_all "DATE_SUB(NOW(),INTERVAL 6 HOUR) &gt; 
     updated_at and BIT_LENGTH(data) &lt;= 688"
  end
end
</code></pre>

<p>This says nuke all sessions which are over 6 hours old, and which are empty.  (688 is the length of the serialized session with an empty flash)</p>

<p>MySQL specific, and susceptible to changes in either session structure or its serialization.  But it was quick and easy and worked for me.</p>

<p>Then you simply need a cron job like: <code>ruby script/runner  'CGI::Session::ActiveRecordStore::Session.flush_old_empty_sessions'</code></p>
]]></content:encoded>
			<wfw:commentRss>http://laughingmeme.org/2005/12/07/flushing-rails-database-mysql-sessions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Anacron for Mac OS X</title>
		<link>http://laughingmeme.org/2004/11/16/anacron-for-mac-os-x/</link>
		<comments>http://laughingmeme.org/2004/11/16/anacron-for-mac-os-x/#comments</comments>
		<pubDate>Wed, 17 Nov 2004 03:38:30 +0000</pubDate>
		<dc:creator>Kellan</dc:creator>
				<category><![CDATA[Aside]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://lm.quxx.info/?p=2651</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[
<p><a href='http://www.alastairs-place.net/anacron.html'>http://www.alastairs-place.net/anacron.html</a></p>]]></content:encoded>
			<wfw:commentRss>http://laughingmeme.org/2004/11/16/anacron-for-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

