Is there any built-in auto-cleanup of the "tmp" directory?

I need to generate some files that I only need for the duration of a
user’s session.

If I create these files in the Rails “tmp” directory, is there any
automagic process that will periodically clean out the “tmp” directory,
or is that something that I would have to manage myself?

Thanks,
Wes

I need to generate some files that I only need for the duration of a
user’s session.

If I create these files in the Rails “tmp” directory, is there any
automagic process that will periodically clean out the “tmp” directory,
or is that something that I would have to manage myself?

rake tmp:cache:clear # Clears all files and directories
in tmp/cache
rake tmp:clear # Clear session, cache, and socket
files from tmp/
rake tmp:create # Creates tmp directories for
sessions, cache, and sockets
rake tmp:sessions:clear # Clears all files in tmp/sessions
rake tmp:sockets:clear # Clears all files in tmp/sockets

Add one or more of those to your crontab file and that should do it for
you…

-philip

1 Like

Philip H. wrote:

I need to generate some files that I only need for the duration of a
user’s session.

If I create these files in the Rails “tmp” directory, is there any
automagic process that will periodically clean out the “tmp” directory,
or is that something that I would have to manage myself?

rake tmp:cache:clear # Clears all files and directories
in tmp/cache
rake tmp:clear # Clear session, cache, and socket
files from tmp/
rake tmp:create # Creates tmp directories for
sessions, cache, and sockets
rake tmp:sessions:clear # Clears all files in tmp/sessions
rake tmp:sockets:clear # Clears all files in tmp/sockets

Add one or more of those to your crontab file and that should do it for
you…

-philip

Keep in mind, clearing sessions will kill all active sessions to. I
don’t recommend that. You could create a model called:

PeriodicNightly with something like this in it:

def self.run
CGI::Session::ActiveRecordStore::Session.
destroy_all( [‘updated_at <?’, 48.hours.ago] )
end

then cron your script/runner like this

script/runner -e production PeriodicNightly.run

Actually, I’m not interested in killing sessions.

I wanted to know if I created my own directory under tmp, say “wes”,
would there ever by any automatic cleanup of that directory.

It appears there isn’t so that I would have to manage it by hand.

Thanks,
Wes

Wes G. wrote:

Actually, I’m not interested in killing sessions.

I wanted to know if I created my own directory under tmp, say “wes”,
would there ever by any automatic cleanup of that directory.

It appears there isn’t so that I would have to manage it by hand.

If you are on Linux/Unix you can write a sh script to rm /path/to/wes/*
and run it
under cron.

Just a thought,

Long
www.edgesoft.ca/blog/read/2