Removing stale Ruby on Rails Sessions on Dreamhost

April 10th, 2007 by benny

Being new to Ruby on Rails, I didn’t really understand the whole session business and was caught off guard when I looked into my tmp/sessions directory. I found upwards of 20,000 Rails session files. After poking around, there are many different ways to store these sessions (and alter them) and ultimately decided I’m too lazy to change it from the default session storing.

I had found this code snippet which allows me to remove stale Rails sessions using cron. However, on Dreamhost, cron does not have an environment so you have to tweak to the following:

* * */4 * * /usr/bin/find /home/benny/ -name "ruby_sess*" -cmin +6000 -exec rm \{} \;

How do you add it? ssh into your dreamhost machine and enter the following line:

$ crontab -i

 

Trackbacks

(Trackback URL)

close Reblog this comment
blog comments powered by Disqus