Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Automatically erase Ruby on Rails session files (See related posts)

Add to your cron:

1 */4 * * *     find /tmp/ -name "ruby_sess*" -cmin +600 -exec rm \{} \;


Deletes sessions over ten hours old every four hours. Otherwise your /tmp will end up overflowing. This only applies you use the file store method of session storage with Rails.

Comments on this post

zaphnod posts on Jul 27, 2006 at 07:11
If you're running on a shared hosting machine (ie there are multiple users all sharing /tmp), you can add "-user <your username>" to the above to restrict your deletion to only your own files. Shouldn't be a problem if the host is configured correctly, but it never hurts!

You need to create an account or log in to post comments to this site.


Click here to browse all 4858 code snippets

Related Posts