[Catalyst] Q: Delete old session data

Tomas Doran bobtfish at bobtfish.net
Mon Jan 25 11:05:05 GMT 2010


Bernhard Graf wrote:
> Is there a recommended way to delete old session data from disk?
> 
> I'm Catalyst::Plugin::Session::Store::File for the session store,
> because it is quite robust. The doc says there is a method
> delete_expired_sessions(), but that module doesn't seem to care about
> expiry at all, so that method seems quite useless.

Deleting all the expired sessions from within a web hit is a bad idea, 
as you're going to have to do an arbitrary amount of work, taking an 
arbitrary amount of time... (There may be several _MILLION_ files to 
delete in an extreme case).

I'd recommend just crontabbing find /tmp/session_dir -mtime +2 | xargs 
rm or something similar.. (I'd probably wrap this in a script which is a 
bit smarter and reports / deals with failure better etc, but you get the 
idea)..

Cheers
t0m



More information about the Catalyst mailing list